PageRenderTime 163ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 1ms

/src/emc/usr_intf/pncconf/pncconf.py

https://github.com/narogon/linuxcnc
Python | 8923 lines | 8662 code | 95 blank | 166 comment | 576 complexity | e24b68f9054d31354e6355ec900aa5b2 MD5 | raw file
Possible License(s): 0BSD, LGPL-2.1, LGPL-3.0, MPL-2.0-no-copyleft-exception, LGPL-2.0
  1. #!/usr/bin/python2.4
  2. # -*- encoding: utf-8 -*-
  3. # This is pncconf, a graphical configuration editor for LinuxCNC
  4. # Chris Morley copyright 2009
  5. # This is based from stepconf, a graphical configuration editor for linuxcnc
  6. # Copyright 2007 Jeff Epler <jepler@unpythonic.net>
  7. #
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. _DEBUGSTRING = ["NONE"]
  22. import sys
  23. import os
  24. # this is for importing modules from lib/python/pncconf
  25. BASE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), ".."))
  26. libdir = os.path.join(BASE, "lib", "python","pncconf")
  27. sys.path.insert(0, libdir)
  28. import pwd
  29. import errno
  30. import time
  31. import hashlib
  32. import pickle
  33. import shutil
  34. import math
  35. import getopt
  36. import textwrap
  37. import locale
  38. import copy
  39. import commands
  40. import fnmatch
  41. import subprocess
  42. import gobject
  43. import gtk
  44. import gtk.glade
  45. import gnome.ui
  46. import xml.dom.minidom
  47. import xml.etree.ElementTree
  48. import xml.etree.ElementPath
  49. import traceback
  50. from touchy import preferences
  51. import cairo
  52. import hal
  53. #import mesatest
  54. def get_value(w):
  55. try:
  56. return w.get_value()
  57. except AttributeError:
  58. pass
  59. oldlocale = locale.getlocale(locale.LC_NUMERIC)
  60. try:
  61. locale.setlocale(locale.LC_NUMERIC, "")
  62. return locale.atof(w.get_text())
  63. finally:
  64. locale.setlocale(locale.LC_NUMERIC, oldlocale)
  65. # otherwise, on hardy the user is shown spurious "[application] closed
  66. # unexpectedly" messages but denied the ability to actually "report [the]
  67. # problem"
  68. def excepthook(exc_type, exc_obj, exc_tb):
  69. try:
  70. w = app.widgets.window1
  71. except NameError:
  72. w = None
  73. lines = traceback.format_exception(exc_type, exc_obj, exc_tb)
  74. m = gtk.MessageDialog(w,
  75. gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
  76. gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
  77. _("PNCconf encountered an error. The following "
  78. "information may be useful in troubleshooting:\n\n")
  79. + "".join(lines))
  80. m.show()
  81. m.run()
  82. m.destroy()
  83. sys.excepthook = excepthook
  84. BASE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), ".."))
  85. LOCALEDIR = os.path.join(BASE, "share", "locale")
  86. import gettext;
  87. #def _(x): return x
  88. gettext.install("linuxcnc", localedir=LOCALEDIR, unicode=True)
  89. gtk.glade.bindtextdomain("linuxcnc", LOCALEDIR)
  90. gtk.glade.textdomain("linuxcnc")
  91. def iceil(x):
  92. if isinstance(x, (int, long)): return x
  93. if isinstance(x, basestring): x = float(x)
  94. return int(math.ceil(x))
  95. datadir = os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "share", "linuxcnc")
  96. wizard = os.path.join(datadir, "linuxcnc-wizard.gif")
  97. if not os.path.isfile(wizard):
  98. wizard = os.path.join("/etc/linuxcnc/linuxcnc-wizard.gif")
  99. if not os.path.isfile(wizard):
  100. linuxcncicon = os.path.join("/usr/share/linuxcnc/linuxcnc-wizard.gif")
  101. if not os.path.isfile(wizard):
  102. wizdir = os.path.join(os.path.abspath(os.path.dirname(__file__)), "..")
  103. wizard = os.path.join(wizdir, "linuxcnc-wizard.gif")
  104. icondir = os.path.join(os.path.abspath(os.path.dirname(__file__)), "..")
  105. linuxcncicon = os.path.join(icondir, "linuxcncicon.png")
  106. if not os.path.isfile(linuxcncicon):
  107. linuxcncicon = os.path.join("/etc/linuxcnc/linuxcnc-wizard.gif")
  108. if not os.path.isfile(linuxcncicon):
  109. linuxcncicon = os.path.join("/usr/share/linuxcnc/linuxcncicon.png")
  110. distdir = os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "configs", "common")
  111. if not os.path.isdir(distdir):
  112. distdir = os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "share", "doc", "linuxcnc", "sample-configs", "common")
  113. if not os.path.isdir(distdir):
  114. distdir = os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "linuxcnc", "sample-configs", "common")
  115. if not os.path.isdir(distdir):
  116. distdir = "/usr/share/doc/linuxcnc/examples/sample-configs/common"
  117. helpdir = os.path.join(BASE, "share", "linuxcnc", "pncconf", "pncconf-help")
  118. if not os.path.exists(helpdir):
  119. helpdir = os.path.join(BASE, "src", "emc", "usr_intf", "pncconf", "pncconf-help")
  120. firmdir = "/lib/firmware/hm2/"
  121. themedir = "/usr/share/themes"
  122. mesablacklist = ["5i22","7i43","4i65","4i68","SVST8_3P.xml"]
  123. # internalname / displayed name / steptime / step space / direction hold / direction setup
  124. drivertypes = [
  125. ["gecko201", _("Gecko 201"), 500, 4000, 20000, 1000],
  126. ["gecko202", _("Gecko 202"), 500, 4500, 20000, 1000],
  127. ["gecko203v", _("Gecko 203v"), 1000, 2000, 200 , 200],
  128. ["gecko210", _("Gecko 210"), 500, 4000, 20000, 1000],
  129. ["gecko212", _("Gecko 212"), 500, 4000, 20000, 1000],
  130. ["gecko320", _("Gecko 320"), 3500, 500, 200, 200],
  131. ["gecko540", _("Gecko 540"), 1500, 2500, 700, 700],
  132. ["l297", _("L297"), 500, 4000, 4000, 1000],
  133. ["pmdx150", _("PMDX-150"), 1000, 2000, 1000, 1000],
  134. ["sherline", _("Sherline"), 22000, 22000, 100000, 100000],
  135. ["xylotex", _("Xylotex 8S-3"), 2000, 1000, 200, 200],
  136. ["oem750", _("Parker-Compumotor oem750"), 1000, 1000, 1000, 200000],
  137. ["jvlsmd41", _("JVL-SMD41 or 42"), 500, 500, 2500, 2500],
  138. ["hobbycnc", _("Hobbycnc Pro Chopper"), 2000, 2000, 2000, 2000],
  139. ["keling", _("Keling 4030"), 5000, 5000, 20000, 20000],
  140. ]
  141. ( NUSED, DUMMY ) = pintype_notused = [ _("Not Used"),_("Dummy") ]
  142. ( AMP8I20,DUMMY2 ) = pintype_8i20 = [ _("8i20 Servo Drive"), _("Dummy") ]
  143. ( POTO,POTE,POTD ) = pintype_potentiometer = [ _("POT Output"), _("POT Enable"),_("POT Direction") ]
  144. ( GPIOI, GPIOO, GPIOD) = pintype_gpio = [ _("GPIO Input"),_("GPIO Output"),_("GPIO O Drain") ]
  145. ( ENCA, ENCB, ENCI, ENCM ) = pintype_encoder = [_("Quad Encoder-A"),_("Quad Encoder-B"),_("Quad Encoder-I"),_("Quad Encoder-M") ]
  146. ( MXE0, MXE1, MXEI, MXEM, MXES ) = pintype_muxencoder = [_("Muxed Encoder 0"),_("Muxed Encoder 1"),_("muxed enc"),_("mux enc mask"),_("mux select") ]
  147. ( RES0, RES1, RES2, RES3, RES4, RES5, RESU ) = pintype_resolver = [_("Resolver 0 Encoder"),_("Resolver 1 Encoder"),_("Resolver 2 Encoder"),
  148. _("Resolver 3 Encoder"),_("Resolver 4 Encoder"),_("Resolver 5 Encoder"), "resolver" ]
  149. ( STEPA, STEPB, STEPC, STEPD, STEPE, STEPF ) = pintype_stepper = [_("Step Gen-A"),_("Dir Gen-B"),_("Step/Dir Gen-C"), _("Step/Dir Gen-D"),
  150. _("Step/Dir Gen-E"),_("Step/dir Gen-F") ]
  151. ( PWMP, PWMD, PWME ) = pintype_pwm = [ _("Pulse Width Gen-P"),_("Pulse Width Gen-D"),_("Pulse Width Gen-E") ]
  152. ( PDMP, PDMD, PDME ) = pintype_pdm = [ _("Pulse Density Gen-P"),_("Pulse Density Gen-D"),_("Pulse Density Gen-E") ]
  153. ( UDMU, UDMD, UDME ) = pintype_udm = [ _("Up/Down Mode -Up"),_("Up/Down Mode-Down"),_("Up/Down Mode-Enable") ]
  154. ( TPPWMA,TPPWMB,TPPWMC,TPPWMAN,TPPWMBN,TPPWMCN,TPPWME,TPPWMF ) = pintype_tp_pwm = [ _("Motor Phase A"),_("Motor Phase B"),_("Motor Phase C"),
  155. _("Motor Phase A Not"),_("Motor Phase B Not") ,_("Motor Phase C Not"), _("Motor Enable"), _("Motor Fault") ]
  156. ( TXDATA0,RXDATA0,TXEN0,TXDATA1,RXDATA1,TXEN1,TXDATA2,RXDATA2,TXEN2,TXDATA3,RXDATA3,TXEN3,TXDATA4,RXDATA4,TXEN4,
  157. TXDATA5,RXDATA5,TXEN5,TXDATA6,RXDATA6,TXEN6,TXDATA7,RXDATA7,TXEN7,SS7I76M0,SS7I76M2,SS7I76M3,
  158. SS7I77M0,SS7I77M1,SS7I77M3,SS7I77M4 ) = pintype_sserial = [ _("SMARTSERIAL-P0-TX"),
  159. _("SMARTSERIAL-P0-RX"),_("SMARTSERIAL-P0-EN"), _("SMARTSERIAL-P1-TX"),_("SMARTSERIAL-P1-RX"),_("SMARTSERIAL-P1-EN"),
  160. _("SMARTSERIAL-P2-TX"),_("SMARTSERIAL-P2-RX"),_("SMARTSERIAL-P2-EN"),_("SMARTSERIAL-P3-TX"),_("SMARTSERIAL-P3-RX"),_("SMARTSERIAL-P3-EN"),
  161. _("SMARTSERIAL-P4-TX"),_("SMARTSERIAL-P4-RX"),_("SMARTSERIAL-P4-EN"),_("SMARTSERIAL-P5-TX"),_("SMARTSERIAL-P5-RX"),_("SMARTSERIAL-P5-EN"),
  162. _("SMARTSERIAL-P6-TX"),_("SMARTSERIAL-P6-RX"),_("SMARTSERIAL-P6-EN"),_("SMARTSERIAL-P7-TX"),_("SMARTSERIAL-P7-RX"),_("SMARTSERIAL-P7-EN"),
  163. _("7i76 I/O (SS0)"),_("7i76 I/O (SS2)"),_("7i76 I/O (SS3)"),_("7i77 I/O (SS0)"),_("7i77 Analog (SS1)"),
  164. _("7i77 I/O (SS3)"),_("7i77 Analog (SS4)"),
  165. ]
  166. (ANALOGIN,DUMMY3) = pintype_analog_in = [ _("Analog Input"), _("Dummy")]
  167. _BOARDTITLE = 0;_BOARDNAME = 1;_FIRMWARE = 2;_DIRECTORY = 3;_HALDRIVER = 4;_MAXENC = 5;_ENCPINS = 6;_MAXRES = 7;_RESPINS = 8;_MAXPWM = 9;
  168. _PWMPINS = 10;_MAXTPPWM = 11;_TTPWMPINMS = 12;_MAXSTEP = 13;_STEPPINS = 14;_MAXSSERIALPORTS = 15;_MAXSSERIALCHANNELS = 16;_HASWATCHDOG = 25;
  169. _MAXGPIO = 26;_LOWFREQ = 27;_HIFREQ = 28;_NUMOFCNCTRS = 29;_STARTOFDATA = 30
  170. _SSCOMBOLEN = 60
  171. _AXIS = 1;_TKLINUXCNC = 2;_MINI = 3;_TOUCHY = 4
  172. _IMPERIAL = 0;_METRIC = 1
  173. # board title, boardname, firmwarename, firmware directory,Hal driver name,
  174. # max encoders, number of pins per encoder,
  175. # max resolver gens, # of pins,
  176. # max pwm gens, # of pins
  177. # max tppwmgens , # of pins
  178. # max step gens, number of pins per step gen,
  179. # max smart serial, number of channels,
  180. # spare,spare,spare,spare,spare,spare,spare,spare,
  181. # has watchdog, max GPIOI,
  182. # low frequency rate , hi frequency rate,
  183. # available connector numbers, then list of component type and logical number
  184. mesafirmwaredata = [
  185. ["5i20", "5i20", "SV12", "5i20", "hm2_pci", 12,3, 0,0, 12,3, 0,0, 0,0, 0,0, 0,0,0,0,0,0,0,0, 1, 72 , 33, 100, [2,3,4],
  186. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  187. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  188. [ENCB,5],[ENCA,5],[ENCB,4],[ENCA,4],[ENCI,5],[ENCI,4],[PWMP,5],[PWMP,4],[PWMD,5],[PWMD,4],[PWME,5],[PWME,4],
  189. [ENCB,7],[ENCA,7],[ENCB,6],[ENCA,6],[ENCI,7],[ENCI,6],[PWMP,7],[PWMP,6],[PWMD,7],[PWMD,6],[PWME,7],[PWME,6],
  190. [ENCB,9],[ENCA,9],[ENCB,8],[ENCA,8],[ENCI,9],[ENCI,8],[PWMP,9],[PWMP,8],[PWMD,9],[PWMD,8],[PWME,9],[PWME,8],
  191. [ENCB,11],[ENCA,11],[ENCB,10],[ENCA,10],[ENCI,11],[ENCI,10],[PWMP,11],[PWMP,10],[PWMD,11],[PWMD,10],[PWME,11],[PWME,10] ],
  192. ["5i20", "5i20", "SVST8_4", "5i20", "hm2_pci", 8,3, 0,0, 8,3, 0,0, 4,2, 0,0, 0,0,0,0,0,0,0,0, 1, 72, 33, 100, [2,3,4],
  193. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  194. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  195. [ENCB,5],[ENCA,5],[ENCB,4],[ENCA,4],[ENCI,5],[ENCI,4],[PWMP,5],[PWMP,4],[PWMD,5],[PWMD,4],[PWME,5],[PWME,4],
  196. [ENCB,7],[ENCA,7],[ENCB,6],[ENCA,6],[ENCI,7],[ENCI,6],[PWMP,7],[PWMP,6],[PWMD,7],[PWMD,6],[PWME,7],[PWME,6],
  197. [STEPA,0],[STEPB,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,1],[STEPB,1],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  198. [STEPA,2],[STEPB,2],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,3],[STEPB,3],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0] ],
  199. ["5i20", "5i20", "SVST2_4_7I47", "5i20", "hm2_pci", 4,3, 0,0, 2,2, 0,0, 4,2, 0,0, 0,0,0,0,0,0,0,0, 1, 72, 33, 100, [2,3,4],
  200. [STEPA,0],[STEPB,0],[STEPA,1],[STEPB,1],[ENCA,0],[ENCA,2],[ENCB,0],[ENCB,2],[ENCI,0],[ENCI,2],[ENCA,1],[ENCA,3],
  201. [ENCB,1],[ENCB,3],[ENCI,1],[ENCI,3],[STEPA,2],[STEPB,2],[STEPA,3],[STEPB,3],[PWMP,0],[PWMD,0],[PWMP,1],[PWMD,1],
  202. [GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  203. [GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  204. [GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  205. [GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0], ],
  206. ["5i20", "5i20", "SVST2_8", "5i20", "hm2_pci", 2,3, 0,0, 2,3, 0,0, 8,6, 0,0, 0,0,0,0,0,0,0,0, 1, 72, 33, 100, [2,3,4],
  207. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  208. [GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  209. [STEPA,0],[STEPB,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,1],[STEPB,1],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  210. [STEPA,2],[STEPB,2],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,3],[STEPB,3],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  211. [STEPA,4],[STEPB,4],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,5],[STEPB,5],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  212. [STEPA,6],[STEPB,6],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,7],[STEPB,7],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0] ],
  213. ["5i20", "5i20", "SVST8_4IM2", "5i20", "hm2_pci", 8,4, 0,0, 8,4, 0,0, 4,2, 0,0, 1, 72, 33, 100, [2,3,4],
  214. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  215. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  216. [ENCB,5],[ENCA,5],[ENCB,4],[ENCA,4],[ENCI,5],[ENCI,4],[PWMP,5],[PWMP,4],[PWMD,5],[PWMD,4],[PWME,5],[PWME,4],
  217. [ENCB,7],[ENCA,7],[ENCB,6],[ENCA,6],[ENCI,7],[ENCI,6],[PWMP,7],[PWMP,6],[PWMD,7],[PWMD,6],[PWME,7],[PWME,6],
  218. [ENCM,0],[ENCM,1],[ENCM,2],[ENCM,3],[ENCM,4],[ENCM,5],[ENCM,6],[ENCM,7],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  219. [GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,0],[STEPB,0],[STEPA,1],[STEPB,1],[STEPA,2],[STEPB,2],[STEPA,3],[STEPB,3] ],
  220. ["5i22-1", "5i22", "SV16", "5i22-1", "hm2_pci", 16,3, 0,0, 16,3, 0,0, 0,0, 0,0,0,0,0,0,0,0, 1, 96, 48, 96, [2,3,4,5],
  221. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  222. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  223. [ENCB,5],[ENCA,5],[ENCB,4],[ENCA,4],[ENCI,5],[ENCI,4],[PWMP,5],[PWMP,4],[PWMD,5],[PWMD,4],[PWME,5],[PWME,4],
  224. [ENCB,7],[ENCA,7],[ENCB,6],[ENCA,6],[ENCI,7],[ENCI,6],[PWMP,7],[PWMP,6],[PWMD,7],[PWMD,6],[PWME,7],[PWME,6],
  225. [ENCB,9],[ENCA,9],[ENCB,8],[ENCA,8],[ENCI,9],[ENCI,8],[PWMP,9],[PWMP,8],[PWMD,9],[PWMD,8],[PWME,9],[PWME,8],
  226. [ENCB,11],[ENCA,11],[ENCB,10],[ENCA,10],[ENCI,11],[ENCI,10],[PWMP,11],[PWMP,10],[PWMD,11],[PWMD,10],[PWME,11],[PWME,10],
  227. [ENCB,13],[ENCA,13],[ENCB,12],[ENCA,12],[ENCI,13],[ENCI,12],[PWMP,13],[PWMP,12],[PWMD,13],[PWMD,12],[PWME,13],[PWME,12],
  228. [ENCB,15],[ENCA,15],[ENCB,14],[ENCA,14],[ENCI,15],[ENCI,14],[PWMP,15],[PWMP,14],[PWMD,15],[PWMD,14],[PWME,15],[PWME,14] ],
  229. ["5i22-1", "5i22", "SVST8_8", "5i22-1", "hm2_pci", 8,3, 0,0, 8,3, 0,0, 8,6, 0,0, 0,0,0,0,0,0,0,0, 1, 96, 48, 96, [2,3,4,5],
  230. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  231. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  232. [ENCB,5],[ENCA,5],[ENCB,4],[ENCA,4],[ENCI,5],[ENCI,4],[PWMP,5],[PWMP,4],[PWMD,5],[PWMD,4],[PWME,5],[PWME,4],
  233. [ENCB,7],[ENCA,7],[ENCB,6],[ENCA,6],[ENCI,7],[ENCI,6],[PWMP,7],[PWMP,6],[PWMD,7],[PWMD,6],[PWME,7],[PWME,6],
  234. [STEPA,0],[STEPB,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,1],[STEPB,1],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  235. [STEPA,2],[STEPB,2],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,3],[STEPB,3],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  236. [STEPA,4],[STEPB,4],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,5],[STEPB,5],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  237. [STEPA,6],[STEPB,6],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,7],[STEPB,7],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0] ],
  238. ["5i22-1", "5i22", "SVST8_24", "5i22-1", "hm2_pci", 8,3, 0,0, 8,3, 0,0, 24,2, 0,0, 1, 96, 48, 96, [2,3,4,5],
  239. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  240. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  241. [ENCB,5],[ENCA,5],[ENCB,4],[ENCA,4],[ENCI,5],[ENCI,4],[PWMP,5],[PWMP,4],[PWMD,5],[PWMD,4],[PWME,5],[PWME,4],
  242. [ENCB,7],[ENCA,7],[ENCB,6],[ENCA,6],[ENCI,7],[ENCI,6],[PWMP,7],[PWMP,6],[PWMD,7],[PWMD,6],[PWME,7],[PWME,6],
  243. [STEPA,0],[STEPB,0],[STEPA,1],[STEPB,1],[STEPA,2],[STEPB,2],[STEPA,3],[STEPB,3],[STEPA,4],[STEPB,4],[STEPA,5],[STEPB,5],
  244. [STEPA,6],[STEPB,6],[STEPA,7],[STEPB,7],[STEPA,8],[STEPB,8],[STEPA,9],[STEPB,9],[STEPA,10],[STEPB,10],[STEPA,11],[STEPB,11],
  245. [STEPA,12],[STEPB,12],[STEPA,13],[STEPB,13],[STEPA,14],[STEPB,14],[STEPA,15],[STEPB,15],[STEPA,16],[STEPB,16],[STEPA,17],[STEPB,17],
  246. [STEPA,18],[STEPB,18],[STEPA,19],[STEPB,19],[STEPA,20],[STEPB,20],[STEPA,21],[STEPB,21],[STEPA,22],[STEPB,22],[STEPA,23],[STEPB,23] ],
  247. ["5i22-1.5", "5i22", "SV16", "5i22-1.5", "hm2_pci", 16,3, 0,0, 16,3, 0,0, 0,0, 0,0, 0,0,0,0,0,0,0,0, 1, 96, 48, 96, [2,3,4,5],
  248. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  249. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  250. [ENCB,5],[ENCA,5],[ENCB,4],[ENCA,4],[ENCI,5],[ENCI,4],[PWMP,5],[PWMP,4],[PWMD,5],[PWMD,4],[PWME,5],[PWME,4],
  251. [ENCB,7],[ENCA,7],[ENCB,6],[ENCA,6],[ENCI,7],[ENCI,6],[PWMP,7],[PWMP,6],[PWMD,7],[PWMD,6],[PWME,7],[PWME,6],
  252. [ENCB,9],[ENCA,9],[ENCB,8],[ENCA,8],[ENCI,9],[ENCI,8],[PWMP,9],[PWMP,8],[PWMD,9],[PWMD,8],[PWME,9],[PWME,8],
  253. [ENCB,11],[ENCA,11],[ENCB,10],[ENCA,10],[ENCI,11],[ENCI,10],[PWMP,11],[PWMP,10],[PWMD,11],[PWMD,10],[PWME,11],[PWME,10],
  254. [ENCB,13],[ENCA,13],[ENCB,12],[ENCA,12],[ENCI,13],[ENCI,12],[PWMP,13],[PWMP,12],[PWMD,13],[PWMD,12],[PWME,13],[PWME,12],
  255. [ENCB,15],[ENCA,15],[ENCB,14],[ENCA,14],[ENCI,15],[ENCI,14],[PWMP,15],[PWMP,14],[PWMD,15],[PWMD,14],[PWME,15],[PWME,14] ],
  256. ["5i22-1.5", "5i22", "SVST8_8", "5i22-1.5", "hm2_pci", 8,3, 0,0, 8,3, 0,0, 8,6, 0,0, 0,0,0,0,0,0,0,0, 1, 96, 48, 96, [2,3,4,5],
  257. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  258. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  259. [ENCB,5],[ENCA,5],[ENCB,4],[ENCA,4],[ENCI,5],[ENCI,4],[PWMP,5],[PWMP,4],[PWMD,5],[PWMD,4],[PWME,5],[PWME,4],
  260. [ENCB,7],[ENCA,7],[ENCB,6],[ENCA,6],[ENCI,7],[ENCI,6],[PWMP,7],[PWMP,6],[PWMD,7],[PWMD,6],[PWME,7],[PWME,6],
  261. [STEPA,0],[STEPB,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,1],[STEPB,1],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  262. [STEPA,2],[STEPB,2],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,3],[STEPB,3],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  263. [STEPA,4],[STEPB,4],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,5],[STEPB,5],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  264. [STEPA,6],[STEPB,6],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,7],[STEPB,7],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0] ],
  265. ["5i22-1.5", "5i22", "SVS8_24", "5i22-1.5", "hm2_pci", 8,3, 0,0, 8,3, 0,0, 24,2, 0,0, 0,0,0,0,0,0,0,0, 1, 96, 48, 96, [2,3,4,5],
  266. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  267. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  268. [ENCB,5],[ENCA,5],[ENCB,4],[ENCA,4],[ENCI,5],[ENCI,4],[PWMP,5],[PWMP,4],[PWMD,5],[PWMD,4],[PWME,5],[PWME,4],
  269. [ENCB,7],[ENCA,7],[ENCB,6],[ENCA,6],[ENCI,7],[ENCI,6],[PWMP,7],[PWMP,6],[PWMD,7],[PWMD,6],[PWME,7],[PWME,6],
  270. [STEPA,0],[STEPB,0],[STEPA,1],[STEPB,1],[STEPA,2],[STEPB,2],[STEPA,3],[STEPB,3],[STEPA,4],[STEPB,4],[STEPA,5],[STEPB,5],
  271. [STEPA,6],[STEPB,6],[STEPA,7],[STEPB,7],[STEPA,8],[STEPB,8],[STEPA,9],[STEPB,9],[STEPA,10],[STEPB,10],[STEPA,11],[STEPB,11],
  272. [STEPA,12],[STEPB,12],[STEPA,13],[STEPB,13],[STEPA,14],[STEPB,14],[STEPA,15],[STEPB,15],[STEPA,16],[STEPB,16],[STEPA,17],[STEPB,17],
  273. [STEPA,18],[STEPB,18],[STEPA,19],[STEPB,19],[STEPA,20],[STEPB,20],[STEPA,21],[STEPB,21],[STEPA,22],[STEPB,22],[STEPA,23],[STEPB,23] ],
  274. ["5i23", "5i23", "SV12", "5i23", "hm2_pci", 12,3, 0,0, 12,3, 0,0, 0,0, 0,0, 0,0,0,0,0,0,0,0, 1, 72 , 48, 96, [2,3,4],
  275. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  276. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  277. [ENCB,5],[ENCA,5],[ENCB,4],[ENCA,4],[ENCI,5],[ENCI,4],[PWMP,5],[PWMP,4],[PWMD,5],[PWMD,4],[PWME,5],[PWME,4],
  278. [ENCB,7],[ENCA,7],[ENCB,6],[ENCA,6],[ENCI,7],[ENCI,6],[PWMP,7],[PWMP,6],[PWMD,7],[PWMD,6],[PWME,7],[PWME,6],
  279. [ENCB,9],[ENCA,9],[ENCB,8],[ENCA,8],[ENCI,9],[ENCI,8],[PWMP,9],[PWMP,8],[PWMD,9],[PWMD,8],[PWME,9],[PWME,8],
  280. [ENCB,11],[ENCA,11],[ENCB,10],[ENCA,10],[ENCI,11],[ENCI,10],[PWMP,11],[PWMP,10],[PWMD,11],[PWMD,10],[PWME,11],[PWME,10] ],
  281. ["5i23", "5i23", "SVST8_4", "5i23", "hm2_pci", 8,3, 0,0, 8,3, 0,0, 4,6, 0,0, 0,0,0,0,0,0,0,0, 1, 72, 48, 96, [2,3,4],
  282. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  283. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  284. [ENCB,5],[ENCA,5],[ENCB,4],[ENCA,4],[ENCI,5],[ENCI,4],[PWMP,5],[PWMP,4],[PWMD,5],[PWMD,4],[PWME,5],[PWME,4],
  285. [ENCB,7],[ENCA,7],[ENCB,6],[ENCA,6],[ENCI,7],[ENCI,6],[PWMP,7],[PWMP,6],[PWMD,7],[PWMD,6],[PWME,7],[PWME,6],
  286. [STEPA,0],[STEPB,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,1],[STEPB,1],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  287. [STEPA,2],[STEPB,2],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,3],[STEPB,3],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0] ],
  288. ["5i23", "5i23", "SVST4_8", "5i23", "hm2_pci", 4,3, 0,0, 4,3, 0,0, 8,6, 0,0, 0,0,0,0,0,0,0,0, 1, 72, 48, 96, [2,3,4],
  289. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  290. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  291. [STEPA,0],[STEPB,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,1],[STEPB,1],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  292. [STEPA,2],[STEPB,2],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,3],[STEPB,3],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  293. [STEPA,4],[STEPB,4],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,5],[STEPB,5],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  294. [STEPA,6],[STEPB,6],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,7],[STEPB,7],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0] ],
  295. ["7i43-2", "7i43", "SV8", "7i43-2", "hm2_7i43", 8,3, 0,0, 8,3, 0,0, 0,0, 0,0, 0,0,0,0,0,0,0,0, 1, 48, 50, 100, [4,3],
  296. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  297. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  298. [ENCB,5],[ENCA,5],[ENCB,4],[ENCA,4],[ENCI,5],[ENCI,4],[PWMP,5],[PWMP,4],[PWMD,5],[PWMD,4],[PWME,5],[PWME,4],
  299. [ENCB,7],[ENCA,7],[ENCB,6],[ENCA,6],[ENCI,7],[ENCI,6],[PWMP,7],[PWMP,6],[PWMD,7],[PWMD,6],[PWME,7],[PWME,6] ],
  300. ["7i43-2", "7i43", "SVST4_4", "7i43-2", "hm2_7i43", 4,3, 0,0, 4,3, 0,0, 4,6, 0,0, 0,0,0,0,0,0,0,0, 1, 48, 50, 100, [4,3],
  301. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  302. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  303. [STEPA,0],[STEPB,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,1],[STEPB,1],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  304. [STEPA,2],[STEPB,2],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,3],[STEPB,3],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0] ],
  305. ["7i43-2", "7i43", "SVST4_6", "7i43-2", "hm2_7i43", 4,4, 0,0, 6,6, 0,0, 3,4, 0,0, 0,0,0,0,0,0,0,0, 1, 48, 50, 100, [4,3],
  306. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  307. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  308. [STEPA,0],[STEPB,0],[GPIOI,0],[GPIOI,0],[STEPA,1],[STEPB,1],[GPIOI,0],[GPIOI,0],[STEPA,2],[STEPB,2],[GPIOI,0],[GPIOI,0],
  309. [STEPA,3],[STEPB,3],[GPIOI,0],[GPIOI,0],[STEPA,4],[STEPB,4],[GPIOI,0],[GPIOI,0],[STEPA,5],[STEPB,5],[GPIOI,0],[GPIOI,0] ],
  310. ["7i43-4", "7i43", "SV8", "7i43-4", "hm2_7i43", 8,3, 0,0, 8,3, 0,0, 0,0, 0,0, 0,0,0,0,0,0,0,0, 1, 48, 50, 100, [4,3],
  311. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  312. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  313. [ENCB,5],[ENCA,5],[ENCB,4],[ENCA,4],[ENCI,5],[ENCI,4],[PWMP,5],[PWMP,4],[PWMD,5],[PWMD,4],[PWME,5],[PWME,4],
  314. [ENCB,7],[ENCA,7],[ENCB,6],[ENCA,6],[ENCI,7],[ENCI,6],[PWMP,7],[PWMP,6],[PWMD,7],[PWMD,6],[PWME,7],[PWME,6] ],
  315. ["7i43-4", "7i43", "SVST4_4", "7i43-4", "hm2_7i43", 4,3, 0,0, 4,3, 0,0, 4,6, 0,0, 0,0,0,0,0,0,0,0, 1, 48, 50, 100, [4,3],
  316. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  317. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  318. [STEPA,0],[STEPB,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,1],[STEPB,1],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],
  319. [STEPA,2],[STEPB,2],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0],[STEPA,3],[STEPB,3],[GPIOI,0],[GPIOI,0],[GPIOI,0],[GPIOI,0] ],
  320. ["7i43-4", "7i43", "SVST4_6", "7i43-4", "hm2_7i43", 4,3, 0,0, 4,3, 0,0, 6,4, 0,0, 0,0,0,0,0,0,0,0, 1, 48, 50, 100, [4,3],
  321. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  322. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  323. [STEPA,0],[STEPB,0],[GPIOI,0],[GPIOI,0],[STEPA,1],[STEPB,1],[GPIOI,0],[GPIOI,0],[STEPA,2],[STEPB,2],[GPIOI,0],[GPIOI,0],
  324. [STEPA,3],[STEPB,3],[GPIOI,0],[GPIOI,0],[STEPA,4],[STEPB,4],[GPIOI,0],[GPIOI,0],[STEPA,5],[STEPB,5],[GPIOI,0],[GPIOI,0] ],
  325. ["7i43-4", "7i43", "SVST4_12", "7i43-4", "hm2_7i43", 4,3, 0,0, 4,3, 0,0, 12,2, 0,0, 0,0,0,0,0,0,0,0, 1, 48, 50, 100, [4,3],
  326. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  327. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  328. [STEPA,0],[STEPB,0],[STEPA,1],[STEPB,1],[STEPA,2],[STEPB,2],[STEPA,3],[STEPB,3],[STEPA,4],[STEPB,4],[STEPA,5],[STEPB,5],
  329. [STEPA,6],[STEPB,6],[STEPA,7],[STEPB,7],[STEPA,8],[STEPB,8],[STEPA,9],[STEPB,9],[STEPA,10],[STEPB,10],[STEPA,11],[STEPB,11] ],
  330. ["3x20-1", "3x20", "SV24", "3x20-1", "hm2_pci", 24,3, 0,0, 24,3, 0,0, 0,0, 0,0, 0,0,0,0,0,0,0,0, 1, 144, 50, 100, [4,5,6,9,8,7],
  331. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  332. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  333. [ENCB,5],[ENCA,5],[ENCB,4],[ENCA,4],[ENCI,5],[ENCI,4],[PWMP,5],[PWMP,4],[PWMD,5],[PWMD,4],[PWME,5],[PWME,4],
  334. [ENCB,7],[ENCA,7],[ENCB,6],[ENCA,6],[ENCI,7],[ENCI,6],[PWMP,7],[PWMP,6],[PWMD,7],[PWMD,6],[PWME,7],[PWME,6],
  335. [ENCB,9],[ENCA,9],[ENCB,8],[ENCA,8],[ENCI,9],[ENCI,8],[PWMP,9],[PWMP,8],[PWMD,9],[PWMD,8],[PWME,9],[PWME,8],
  336. [ENCB,11],[ENCA,11],[ENCB,10],[ENCA,10],[ENCI,11],[ENCI,10],[PWMP,11],[PWMP,10],[PWMD,11],[PWMD,10],[PWME,11],[PWME,10],
  337. [ENCB,13],[ENCA,13],[ENCB,12],[ENCA,12],[ENCI,13],[ENCI,12],[PWMP,13],[PWMP,12],[PWMD,13],[PWMD,12],[PWME,13],[PWME,12],
  338. [ENCB,15],[ENCA,15],[ENCB,14],[ENCA,14],[ENCI,15],[ENCI,14],[PWMP,15],[PWMP,14],[PWMD,15],[PWMD,14],[PWME,15],[PWME,14],
  339. [ENCB,17],[ENCA,17],[ENCB,16],[ENCA,16],[ENCI,17],[ENCI,16],[PWMP,17],[PWMP,16],[PWMD,17],[PWMD,16],[PWME,17],[PWME,16],
  340. [ENCB,19],[ENCA,19],[ENCB,18],[ENCA,18],[ENCI,19],[ENCI,18],[PWMP,19],[PWMP,18],[PWMD,19],[PWMD,18],[PWME,19],[PWME,18],
  341. [ENCB,21],[ENCA,21],[ENCB,20],[ENCA,20],[ENCI,21],[ENCI,20],[PWMP,21],[PWMP,20],[PWMD,21],[PWMD,20],[PWME,21],[PWME,20],
  342. [ENCB,23],[ENCA,23],[ENCB,22],[ENCA,22],[ENCI,23],[ENCI,22],[PWMP,23],[PWMP,22],[PWMD,23],[PWMD,22],[PWME,23],[PWME,22] ],
  343. ["3x20-1", "3x20", "SVST16_24", "3x20-1", "hm2_pci", 16,3, 0,0, 16,3, 0,0, 24,2, 0,0, 0,0,0,0,0,0,0,0, 1, 144, 50, 100, [4,5,6,9,8,7],
  344. [ENCB,1],[ENCA,1],[ENCB,0],[ENCA,0],[ENCI,1],[ENCI,0],[PWMP,1],[PWMP,0],[PWMD,1],[PWMD,0],[PWME,1],[PWME,0],
  345. [ENCB,3],[ENCA,3],[ENCB,2],[ENCA,2],[ENCI,3],[ENCI,2],[PWMP,3],[PWMP,2],[PWMD,3],[PWMD,2],[PWME,3],[PWME,2],
  346. [ENCB,5],[ENCA,5],[ENCB,4],[ENCA,4],[ENCI,5],[ENCI,4],[PWMP,5],[PWMP,4],[PWMD,5],[PWMD,4],[PWME,5],[PWME,4],
  347. [ENCB,7],[ENCA,7],[ENCB,6],[ENCA,6],[ENCI,7],[ENCI,6],[PWMP,7],[PWMP,6],[PWMD,7],[PWMD,6],[PWME,7],[PWME,6],
  348. [ENCB,9],[ENCA,9],[ENCB,8],[ENCA,8],[ENCI,9],[ENCI,8],[PWMP,9],[PWMP,8],[PWMD,9],[PWMD,8],[PWME,9],[PWME,8],
  349. [ENCB,11],[ENCA,11],[ENCB,10],[ENCA,10],[ENCI,11],[ENCI,10],[PWMP,11],[PWMP,10],[PWMD,11],[PWMD,10],[PWME,11],[PWME,10],
  350. [ENCB,13],[ENCA,13],[ENCB,12],[ENCA,12],[ENCI,13],[ENCI,12],[PWMP,13],[PWMP,12],[PWMD,13],[PWMD,12],[PWME,13],[PWME,12],
  351. [ENCB,15],[ENCA,15],[ENCB,14],[ENCA,14],[ENCI,15],[ENCI,14],[PWMP,15],[PWMP,14],[PWMD,15],[PWMD,14],[PWME,15],[PWME,14],
  352. [STEPA,0],[STEPB,0],[STEPA,1],[STEPB,1],[STEPA,2],[STEPB,2],[STEPA,3],[STEPB,3],[STEPA,4],[STEPB,4],[STEPA,5],[STEPB,5],
  353. [STEPA,6],[STEPB,6],[STEPA,7],[STEPB,7],[STEPA,8],[STEPB,8],[STEPA,9],[STEPB,9],[STEPA,10],[STEPB,10],[STEPA,11],[STEPB,11],
  354. [STEPA,12],[STEPB,12],[STEPA,13],[STEPB,13],[STEPA,14],[STEPB,14],[STEPA,15],[STEPB,15],[STEPA,16],[STEPB,16],[STEPA,17],[STEPB,17],
  355. [STEPA,18],[STEPB,18],[STEPA,19],[STEPB,19],[STEPA,20],[STEPB,20],[STEPA,21],[STEPB,21],[STEPA,22],[STEPB,22],[STEPA,23],[STEPB,23] ],
  356. ]
  357. _SUBBOARDNAME = 0; _SUBFIRMNAME = 1; _SUBMODE = 2;_SUBCONLIST = 3;_SUBSTARTOFDATA = 12 # 4-10 spare for now.
  358. mesadaughterdata = [ ["8i20", "8i20", 0,[_("Axis Selection"),"Not Used","Not Used"], 0,0,0,0,0,0,0,0,
  359. [AMP8I20,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],
  360. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],
  361. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],
  362. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],
  363. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],
  364. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],
  365. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0] ],
  366. ["7i64", "7i64", 0,[_("7i64-Input\nP3 and P4"),_("7i64-Output\nP2 and P5"),_("7i64-Analog In")], 0,0,0,0,0,0,0,0,
  367. [GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],
  368. [GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],
  369. [GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],
  370. [GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],
  371. [ANALOGIN,0],[ANALOGIN,1],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],
  372. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],
  373. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0] ],
  374. ["7i69", "7i69", 0,[_("7i69\nP2"),_("7i69\nP3"),"Not Used"], 0,0,0,0,0,0,0,0,
  375. [GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],
  376. [GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],
  377. [GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],
  378. [GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],
  379. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],
  380. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],
  381. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0] ],
  382. ["7i70", "7i70", 0,[_("7i70-Input\nTB3"),_("7i70-Input\nTB2"),"Not Used"], 0,0,0,0,0,0,0,0,
  383. [GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],
  384. [GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],
  385. [GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],
  386. [GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],
  387. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],
  388. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],
  389. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0] ],
  390. ["7i71", "7i71", 0,[_("7i71-Output\nTB3"),_("7i71-Output\nTB2"),"Not Used"], 0,0,0,0,0,0,0,0,
  391. [GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],
  392. [GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],
  393. [GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],
  394. [GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],
  395. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],
  396. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],
  397. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0] ],
  398. ["7i76", "7i76-m0", 0,[_("7i76-I/O\nTB6"),_("7i76-I/O\nTB5"),_("7i76-Analog Output\nTB4")], 0,0,0,0,0,0,0,0,
  399. [GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],
  400. [GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],
  401. [GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],
  402. [GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],
  403. [POTO,0],[POTE,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],
  404. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],
  405. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0] ],
  406. ["7i77", "7i77-m0", 0,[_("7i77-I/O\nTB8"),_("7i77-I/O\nTB7"),_("7i77-Analog Output\nTB5")], 0,0,0,0,0,0,0,0,
  407. [GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],
  408. [GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],
  409. [GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],
  410. [GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],
  411. [PWME,0],[PWMP,0],[PWMD,0],[PWMP,1],[PWMD,1],[PWMP,2],[PWMD,2],[PWMP,3],[PWMD,3],[PWMP,4],[PWMD,4],[PWMP,5],
  412. [PWMD,5],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],
  413. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0] ],
  414. ["7i73", "7i73-m1", 0,[_("7i73-I/O\n"),"7i73-I/O\n ","7i73-Analog/Encoders\n "], 0,0,0,0,0,0,0,0,
  415. [GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],
  416. [GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],[GPIOI,100],
  417. [GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],
  418. [GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[GPIOO,100],[NUSED,0],[NUSED,0],
  419. [ANALOGIN,0],[ANALOGIN,1],[ANALOGIN,2],[ANALOGIN,3],[ENCA,0],[ENCA,1],[ENCA,2],[ENCA,3],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],
  420. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],
  421. [NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0],[NUSED,0] ],
  422. ["error"]
  423. ]
  424. custommesafirmwaredata = []
  425. mesaboardnames = [ "5i20", "5i22-1", "5i22-1.5", "5i23", "7i43-2", "7i43-4","3x20-1" ]
  426. (UNUSED_UNUSED,UNUSED_DUMMY) = hal_notused_names = ["unused-unused","unused_dummy"]
  427. human_notused_names = [ [_("Unused Unused"),[] ] ]
  428. (UNUSED_OUTPUT,
  429. ON, CW, CCW, BRAKE,
  430. MIST, FLOOD, ESTOP, AMP, XAMP, YAMP, ZAMP, AAMP,
  431. PUMP,FORCE_PIN_TRUE, DOUT0, DOUT1, DOUT2, DOUT3,
  432. X_HALL1_OUT,X_HALL2_OUT,X_HALL3_OUT,X_C1_OUT,X_C2_OUT,X_C4_OUT,X_C8_OUT,
  433. Y_HALL1_OUT,Y_HALL2_OUT,Y_HALL3_OUT,Y_C1_OUT,Y_C2_OUT,Y_C4_OUT,Y_C8_OUT,
  434. Z_HALL1_OUT,Z_HALL2_OUT,Z_HALL3_OUT,Z_C1_OUT,Z_C2_OUT,Z_C4_OUT,Z_C8_OUT,
  435. A_HALL1_OUT,A_HALL2_OUT,A_HALL3_OUT,A_C1_OUT,A_C2_OUT,A_C4_OUT,A_C8_OUT,
  436. S_HALL1_OUT,S_HALL2_OUT,S_HALL3_OUT,S_C1_OUT,S_C2_OUT,S_C4_OUT,S_C8_OUT) = hal_output_names = [
  437. "unused-output",
  438. "spindle-on", "spindle-cw", "spindle-ccw", "spindle-brake",
  439. "coolant-mist", "coolant-flood", "estop-out", "machine-is-enabled", "x-enable", "y-enable", "z-enable", "a-enable",
  440. "charge-pump", "force-pin-true", "dout-00", "dout-01", "dout-02", "dout-03",
  441. "x-hall1-out","x-hall2-out","x-hall3-out","x-gray-c1-out","x-gray-c2-out","x-gray-C4-out","x-gray-C8-out",
  442. "y-hall1-out","y-hall2-out","y-hall3-out","y-gray-c1-out","y-gray-c2-out","y-gray-C4-out","y-gray-C8-out",
  443. "z-hall1-out","z-hall2-out","z-hall3-out","z-gray-c1-out","z-gray-c2-out","z-gray-C4-out","z-gray-C8-out",
  444. "a-hall1-out","a-hall2-out","a-hall3-out","a-gray-c1-out","a-gray-c2-out","a-gray-C4-out","a-gray-C8-out",
  445. "s-hall1-out","s-hall2-out","s-hall3-out","s-gray-c1-out","s-gray-c2-out","s-gray-C4-out","s-gray-C8-out", ]
  446. spindle_output = [_("Spindle ON"),_("Spindle CW"), _("Spindle CCW"), _("Spindle Brake") ]
  447. coolant_output = [_("Coolant Mist"), _("Coolant Flood")]
  448. control_output = [_("ESTOP Out"), _("Machine Is Enabled"),_("X Amplifier Enable"),_("Y Amplifier Enable"),_("Z Amplifier Enable"),
  449. _("A Amplifier Enable"),_("Charge Pump"),_("Force Pin True")]
  450. digital_output = [_("Digital out 0"), _("Digital out 1"), _("Digital out 2"), _("Digital out 3")]
  451. xmotor_control = [_("X HALL 1"),_("X HALL 2"),_("X HALL 3"),_("X Gray C1"),_("X Gray C2"),_("X Gray C4"),_("X Gray C8")]
  452. ymotor_control = [_("Y HALL 1"),_("Y HALL 2"),_("Y HALL 3"),_("Y Gray C1"),_("Y Gray C2"),_("Y Gray C4"),_("Y Gray C8")]
  453. zmotor_control = [_("Z HALL 1"),_("Z HALL 2"),_("Z HALL 3"),_("Z Gray C1"),_("Z Gray C2"),_("Z Gray C4"),_("Z Gray C8")]
  454. amotor_control = [_("A HALL 1"),_("A HALL 2"),_("A HALL 3"),_("A Gray C1"),_("A Gray C2"),_("A Gray C4"),_("A Gray C8")]
  455. smotor_control = [_("S HALL 1"),_("S HALL 2"),_("S HALL 3"),_("S Gray C1"),_("S Gray C2"),_("S Gray C4"),_("S Gray C8")]
  456. human_output_names = [ [_("Unused Output"),[]],[_("Spindle"),spindle_output],[_("Coolant"),coolant_output],
  457. [_("Control"),control_output],[_("Digital"),digital_output],[_("X BLDC Control"),xmotor_control],
  458. [_("Y BLDC Control"),ymotor_control],[_("Z BLDC Control"),zmotor_control],[_("A BLDC Control"),amotor_control],
  459. [_(" S BLDC Control"),smotor_control],[_("Custom Signals"),[]] ]
  460. limit = [_("X Minimum Limit"), _("Y Minimum Limit"), _("Z Minimum Limit"), _("A Minimum Limit"),
  461. _("X Maximum Limit"), _("Y Maximum Limit"), _("Z Maximum Limit"), _("A Maximum Limit"),
  462. _("X Both Limit"), _("Y Both Limit"), _("Z Both Limit"), _("A Both Limit"),
  463. _("All Limits") ]
  464. home = [_("X Home"), _("Y Home"), _("Z Home"), _("A Home"),_("All Home") ]
  465. home_limits_shared = [ _("X Minimum Limit + Home"), _("Y Minimum Limit + Home"), _("Z Minimum Limit + Home"), _("A Minimum Limit + Home"),
  466. _("X Maximum Limit + Home"), _("Y Maximum Limit + Home"), _("Z Maximum Limit + Home"), _("A Maximum Limit + Home"),
  467. _("X Both Limit + Home"), _("Y Both Limit + Home"), _("Z Both Limit + Home"), _("A Both Limit + Home") ]
  468. digital = [ _("Digital in 0"), _("Digital in 1"), _("Digital in 2"), _("Digital in 3") ]
  469. axis_select = [_("Joint select A"),_("Joint select B"),_("Joint select C"), _("Joint select D") ]
  470. override = [_("Jog incr A"),_("Jog incr B"),_("Jog incr C"),_("Jog incr D"),_("Feed Override incr A"),_("Feed Override incr B"),
  471. _("Feed Override incr C"),_("Feed Override incr D"),_("Spindle Override incr A"),_("Spindle Override incr B"),
  472. _("Spindle Override incr C"),_("Spindle Override incr D"), _("Max Vel Override incr A"),_("Max Vel Override incr B"),
  473. _("Max Vel Override incr C"),_("Max Vel Override incr D"), _("Feed Override enable"), _("Spindle Override enable"),
  474. _("Max Vel Override enable") ]
  475. spindle = [ _("Manual Spindle CW"),_("Manual Spindle CCW"),_("Manual Spindle Stop"),_("Spindle Up-To-Speed") ]
  476. operation = [_("Cycle Start"),_("Abort"),_("Single Step") ]
  477. control = [_("ESTOP In"), _("Probe In") ]
  478. xmotor_control = [_("X HALL 1"),_("X HALL 2"),_("X HALL 3"),_("X Gray C1"),_("X Gray C2"),_("X Gray C4"),_("X Gray C8")]
  479. ymotor_control = [_("Y HALL 1"),_("Y HALL 2"),_("Y HALL 3"),_("Y Gray C1"),_("Y Gray C2"),_("Y Gray C4"),_("Y Gray C8")]
  480. zmotor_control = [_("Z HALL 1"),_("Z HALL 2"),_("Z HALL 3"),_("Z Gray C1"),_("Z Gray C2"),_("Z Gray C4"),_("Z Gray C8")]
  481. amotor_control = [_("A HALL 1"),_("A HALL 2"),_("A HALL 3"),_("A Gray C1"),_("A Gray C2"),_("A Gray C4"),_("A Gray C8")]
  482. smotor_control = [_("S HALL 1"),_("S HALL 2"),_("S HALL 3"),_("S Gray C1"),_("S Gray C2"),_("S Gray C4"),_("S Gray C8")]
  483. rapid = [_("Jog X +"),_("Jog X -"),_("Jog Y +"),_("Jog Y -"),_("Jog Z +"),_("Jog Z -"),_("Jog A +"),_("Jog A -"),
  484. _("Jog button selected +"),_("Jog button selected -") ]
  485. human_input_names = [ [_("Unused Input"),[]],[_("Limits"),limit],[_("Home"),home],[_("Limts/Home Shared"),home_limits_shared],
  486. [_("Digital"),digital],[_("Axis Selection"),axis_select],[_("Overrides"),override],[_("Spindle"),spindle],
  487. [_("Operation"),operation],[_("External Control"),control],[_("Axis rapid"),rapid],[_("X BLDC Control"),xmotor_control],
  488. [_("Y BLDC Control"),ymotor_control],[_("Z BLDC Control"),zmotor_control],[_("A BLDC Control"),amotor_control],
  489. [_("S BLDC Control"),smotor_control],[_("Custom Signals"),[]] ]
  490. (UNUSED_INPUT,
  491. MIN_X, MIN_Y, MIN_Z, MIN_A,
  492. MAX_X, MAX_Y, MAX_Z, MAX_A,
  493. BOTH_X, BOTH_Y, BOTH_Z, BOTH_A,ALL_LIMIT,
  494. HOME_X, HOME_Y, HOME_Z, HOME_A,ALL_HOME,
  495. MIN_HOME_X, MIN_HOME_Y, MIN_HOME_Z, MIN_HOME_A,
  496. MAX_HOME_X, MAX_HOME_Y, MAX_HOME_Z, MAX_HOME_A,
  497. BOTH_HOME_X, BOTH_HOME_Y, BOTH_HOME_Z, BOTH_HOME_A,
  498. DIN0, DIN1, DIN2, DIN3,
  499. SELECT_A, SELECT_B, SELECT_C, SELECT_D,
  500. JOGA, JOGB, JOGC, JOGD, FOA, FOB, FOC, FOD,
  501. SOA,SOB,SOC,SOD, MVOA, MVOB, MVOC, MVOD,
  502. FOE,SOE,MVOE,
  503. SPINDLE_CW, SPINDLE_CCW, SPINDLE_STOP,SPINDLE_AT_SPEED,
  504. CYCLE_START, ABORT, SINGLE_STEP,
  505. ESTOP_IN, PROBE,
  506. JOGX_P,JOGX_N,JOGY_P,JOGY_N,JOGZ_P,JOGZ_N,JOGA_P,JOGA_N,JOGSLCT_P, JOGSLCT_N,
  507. X_HALL1_IN,X_HALL2_IN,X_HALL3_IN,X_C1_IN,X_C2_IN,X_C4_IN,X_C8_IN,
  508. Y_HALL1_IN,Y_HALL2_IN,Y_HALL3_IN,Y_C1_IN,Y_C2_IN,Y_C4_IN,Y_C8_IN,
  509. Z_HALL1_IN,Z_HALL2_IN,Z_HALL3_IN,Z_C1_IN,Z_C2_IN,Z_C4_IN,Z_C8_IN,
  510. A_HALL1_IN,A_HALL2_IN,A_HALL3_IN,A_C1_IN,A_C2_IN,A_C4_IN,A_C8_IN,
  511. S_HALL1_IN,S_HALL2_IN,S_HALL3_IN,S_C1_IN,S_C2_IN,S_C4_IN,S_C8_IN ) = hal_input_names = ["unused-input",
  512. "min-x", "min-y", "min-z", "min-a",
  513. "max-x", "max-y", "max-z", "max-a",
  514. "both-x", "both-y", "both-z", "both-a","all-limit",
  515. "home-x", "home-y", "home-z", "home-a","all-home",
  516. "min-home-x", "min-home-y", "min-home-z", "min-home-a",
  517. "max-home-x", "max-home-y", "max-home-z", "max-home-a",
  518. "both-home-x", "both-home-y", "both-home-z", "both-home-a",
  519. "din-00", "din-01", "din-02", "din-03",
  520. "joint-select-a","joint-select-b","joint-select-c","joint-select-d",
  521. "jog-incr-a","jog-incr-b","jog-incr-c","jog-incr-d","fo-incr-a","fo-incr-b","fo-incr-c","fo-incr-d",
  522. "so-incr-a","so-incr-b","so-incr-c","so-incr-d","mvo-incr-a","mvo-incr-b","mvo-incr-c","mvo-incr-d",
  523. "fo-enable","so-enable","mvo-enable",
  524. "spindle-manual-cw","spindle-manual-ccw","spindle-manual-stop","spindle-at-speed",
  525. "cycle-start","abort","single-step",
  526. "estop-ext", "probe-in",
  527. "jog-x-pos","jog-x-neg","jog-y-pos","jog-y-neg",
  528. "jog-z-pos","jog-z-neg","jog-a-pos","jog-a-neg","jog-selected-pos","jog-selected-neg",
  529. "x-hall1-in","x-hall2-in","x-hall3-in","x-gray-c1-in","x-gray-c2-in","x-gray-C4-in","x-gray-C8-in",
  530. "y-hall1-in","y-hall2-in","y-hall3-in","y-gray-c1-in","y-gray-c2-in","y-gray-C4-in","y-gray-C8-in",
  531. "z-hall1-in","z-hall2-in","z-hall3-in","z-gray-c1-in","z-gray-c2-in","z-gray-C4-in","z-gray-C8-in",
  532. "a-hall1-in","a-hall2-in","a-hall3-in","a-gray-c1-in","a-gray-c2-in","a-gray-C4-in","a-gray-C8-in",
  533. "s-hall1-in","s-hall2-in","s-hall3-in","s-gray-c1-in","s-gray-c2-in","s-gray-C4-in","s-gray-C8-in" ]
  534. human_names_multi_jog_buttons = [_("Jog X +"),_("Jog X -"),
  535. _("Jog Y +"),_("Jog Y -"),
  536. _("Jog Z +"),_("Jog Z -"),
  537. _("Jog A +"),_("Jog A -")]
  538. human_names_shared_home = [_("X Minimum Limit + Home"), _("Y Minimum Limit + Home"),
  539. _("Z Minimum Limit + Home"), _("A Minimum Limit + Home"),
  540. _("X Maximum Limit + Home"), _("Y Maximum Limit + Home"),
  541. _("Z Maximum Limit + Home"), _("A Maximum Limit + Home"),
  542. _("X Both Limit + Home"), _("Y Both Limit + Home"),
  543. _("Z Both Limit + Home"), _("A Both Limit + Home")]
  544. human_names_limit_only = [ _("X Minimum Limit"), _("Y Minimum Limit"),
  545. _("Z Minimum Limit"), _("A Minimum Limit"),
  546. _("X Maximum Limit"), _("Y Maximum Limit"),
  547. _("Z Maximum Limit"), _("A Maximum Limit"),
  548. _("X Both Limit"), _("Y Both Limit"),
  549. _("Z Both Limit"), _("A Both Limit"), _("All Limits")]
  550. (UNUSED_PWM,
  551. X_PWM_PULSE, X_PWM_DIR, X_PWM_ENABLE, Y_PWM_PULSE, Y_PWM_DIR, Y_PWM_ENABLE,
  552. Z_PWM_PULSE, Z_PWM_DIR, Z_PWM_ENABLE, A_PWM_PULSE, A_PWM_DIR, A_PWM_ENABLE,
  553. SPINDLE_PWM_PULSE, SPINDLE_PWM_DIR, SPINDLE_PWM_ENABLE, ) = hal_pwm_output_names = ["unused-pwm",
  554. "x-pwm-pulse", "x-pwm-dir", "x-pwm-enable", "y-pwm-pulse", "y-pwm-dir", "y-pwm-enable",
  555. "z-pwm-pulse", "z-pwm-dir", "z-pwm-enable", "a-pwm-pulse", "a-pwm-dir", "a-pwm-enable",
  556. "s-pwm-pulse", "s-pwm-dir", "s-pwm-enable"]
  557. human_pwm_output_names =[ [_("Unused PWM Gen"),[]],[_("X Axis PWM"),[]],[_("Y Axis PWM"),[]],
  558. [_("Z Axis PWM"),[]],[_("A Axis PWM"),[]],[_("Spindle PWM"),[]],[_("Custom Signals"),[]] ]
  559. (UNUSED_ENCODER,
  560. X_ENCODER_A, X_ENCODER_B, X_ENCODER_I, X_ENCODER_M,
  561. Y_ENCODER_A, Y_ENCODER_B, Y_ENCODER_I, Y_ENCODER_M,
  562. Z_ENCODER_A, Z_ENCODER_B, Z_ENCODER_I, Z_ENCODER_M,
  563. A_ENCODER_A, A_ENCODER_B, A_ENCODER_I, A_ENCODER_M,
  564. SPINDLE_ENCODER_A, SPINDLE_ENCODER_B, SPINDLE_ENCODER_I, SPINDLE_ENCODER_M,
  565. X_MPG_A, X_MPG_B, X_MPG_I, X_MPG_M, Y_MPG_A, Y_MPG_B, Y_MPG_I, Y_MPG_M,
  566. Z_MPG_A, Z_MPG_B, Z_MPG_I, Z_MPG_M, A_MPG_A, A_MPG_B, A_MPG_I,A_MPG_M,
  567. SELECT_MPG_A, SELECT_MPG_B, SELECT_MPG_I, SELECT_MPG_M,
  568. FO_MPG_A,FO_MPG_B,FO_MPG_I,FO_MPG_M,SO_MPG_A,SO_MPG_B,SO_MPG_I,SO_MPG_I,
  569. MVO_MPG_A,MVO_MPG_B,MVO_MPG_I,MVO_MPG_I,) = hal_encoder_input_names = [ "unused-encoder",
  570. "x-encoder-a", "x-encoder-b", "x-encoder-i", "x-encoder-m",
  571. "y-encoder-a", "y-encoder-b", "y-encoder-i", "y-encoder-m",
  572. "z-encoder-a", "z-encoder-b", "z-encoder-i", "z-encoder-m",
  573. "a-encoder-a", "a-encoder-b", "a-encoder-i", "a-encoder-m",
  574. "s-encoder-a","s-encoder-b","s-encoder-i", "s-encoder-m",
  575. "x-mpg-a","x-mpg-b", "x-mpg-i", "x-mpg-m", "y-mpg-a", "y-mpg-b", "y-mpg-i", "y-mpg-m",
  576. "z-mpg-a","z-mpg-b", "z-mpg-i", "z-mpg-m", "a-mpg-a", "a-mpg-b", "a-mpg-i", "a-mpg-m",
  577. "select-mpg-a", "select-mpg-b", "select-mpg-i", "select-mpg-m",
  578. "fo-mpg-a","fo-mpg-b","fo-mpg-i","fo-mpg-m","so-mpg-a","so-mpg-b","so-mpg-i","so-mpg-m",
  579. "mvo-mpg-a","mvo-mpg-b","mvo-mpg-i","mvo-mpg-m"]
  580. axis = [_("X Encoder"),_("Y Encoder"), _("Z Encoder"),_("A Encoder"),_("Spindle Encoder")]
  581. mpg = [_("X Hand Wheel"), _("Y Hand Wheel"), _("Z Hand Wheel"), _("A Hand Wheel") ,_("Multi Hand Wheel")]
  582. over = [_("Feed Override"),_("spindle Override"),_("Max Vel Override")]
  583. human_encoder_input_names = [ [_("Unused Encoder"),[]],[_("Axis Encoder"), axis],[_("MPG Jog Controls"), mpg],[_("Override MPG control"), over],
  584. [_("Custom Signals"),[]] ]
  585. human_resolver_input_names =[ [_("Unused Resolver"),[]],[_("X Resolver"), []],[_("Y Resolver"), []],[_("Z Resolver"), []],
  586. [_("A Resolver"), []],[_("S Resolver"), []],[_("Custom Signals"),[]] ]
  587. USED_RESOLVER,X_RESOLVER,Y_RESOLVER,Z_RESOLVER,A_RESOLVER,S_RESOLVER = hal_resolver_input_names = ["unused-resolver","x-resolver",
  588. "y-resolver","z-resolver","a-resolver","s-resolver"]
  589. human_8i20_input_names =[ [_("Unused 8I20"),[]],[_("X Axis"), []],[_("Y Axis"), []],[_("Z Axis"), []],
  590. [_("A Axis"), []],[_("Spindle"), []],[_("Custom Signals"),[]] ]
  591. USED_8I20,X_8I20,Y_8I20,Z_8I20,A_8I20,S_8I20 = hal_8i20_input_names = ["unused-8i20","x-8i20",
  592. "y-8i20","z-8i20","a-8i20","s-8i20"]
  593. human_pot_output_names =[ [_("Unused Analog Output"),[]],[_("Spindle Output"), []],[_("Custom Signals"),[]] ]
  594. USED_POT,S_POT_OUT,S_POT_ENABLE = hal_pot_output_names = ["unused-pot","s-pot-output","s-pot-enable"]
  595. (UNUSED_STEPGEN,
  596. X_STEPGEN_STEP, X_STEPGEN_DIR, X_STEPGEN_PHC, X_STEPGEN_PHD, X_STEPGEN_PHE, X_STEPGEN_PHF,
  597. Y_STEPGEN_STEP, X_STEPGEN_DIR, X_STEPGEN_PHC, X_STEPGEN_PHD, X_STEPGEN_PHE, X_STEPGEN_PHF,
  598. Z_STEPGEN_STEP, Z_STEPGEN_DIR, Z_STEPGEN_PHC, Z_STEPGEN_PHD, Z_STEPGEN_PHE, Z_STEPGEN_PHF,
  599. A_STEPGEN_STEP, A_STEPGEN_DIR, A_STEPGEN_PHC, A_STEPGEN_PHD, A_STEPGEN_PHE, A_STEPGEN_PHF,
  600. SPINDLE_STEPGEN_STEP, SPINDLE_STEPGEN_DIR, SPINDLE_STEPGEN_PHC, SPINDLE_STEPGEN_PHD, SPINDLE_STEPGEN_PHE, SPINDLE_STEPGEN_PHF,
  601. X2_STEPGEN_STEP, X2_STEPGEN_DIR, X2_STEPGEN_PHC, X2_STEPGEN_PHD, X2_STEPGEN_PHE, X2_STEPGEN_PHF,
  602. Y2_STEPGEN_STEP, Y2_STEPGEN_DIR, Y2_STEPGEN_PHC, Y2_STEPGEN_PHD, Y2_STEPGEN_PHE, Y2_STEPGEN_PHF,
  603. Z2_STEPGEN_STEP, Z2_STEPGEN_DIR, Z2_STEPGEN_PHC, Z2_STEPGEN_PHD, Z2_STEPGEN_PHE, Z2_STEPGEN_PHF,
  604. CHARGE_PUMP_STEP,CHARGE_PUMP_DIR,CHARGE_PUMP_PHC,CHARGE_PUMP_PHD,CHARGE_PUMP_PHE,CHARGE_PUMP_PHF) = hal_stepper_names = ["unused-stepgen",
  605. "x-stepgen-step", "x-stepgen-dir", "x-stepgen-phase-c", "x-stepgen-phase-d", "x-stepgen-phase-e", "x-stepgen-phase-f",
  606. "y-stepgen-step", "y-stepgen-dir", "y-stepgen-phase-c", "y-stepgen-phase-d", "y-stepgen-phase-e", "y-stepgen-phase-f",
  607. "z-stepgen-step", "z-stepgen-dir", "z-stepgen-phase-c", "z-stepgen-phase-d", "z-stepgen-phase-e", "z-stepgen-phase-f",
  608. "a-stepgen-step", "a-stepgen-dir", "a-stepgen-phase-c", "a-stepgen-phase-d", "a-stepgen-phase-e", "a-stepgen-phase-f",
  609. "s-stepgen-step", "s-stepgen-dir", "s-stepgen-phase-c", "s-stepgen-phase-d", "s-stepgen-phase-e", "s-stepgen-phase-f",
  610. "x2-stepgen-step", "x2-stepgen-dir", "x2-stepgen-phase-c", "x2-stepgen-phase-d", "x2-stepgen-phase-e", "x2-stepgen-phase-f",
  611. "y2-stepgen-step", "y2-stepgen-dir", "y2-stepgen-phase-c", "y2-stepgen-phase-d", "y2-stepgen-phase-e", "y2-stepgen-phase-f",
  612. "z2-stepgen-step", "z2-stepgen-dir", "z2-stepgen-phase-c", "z2-stepgen-phase-d", "z2-stepgen-phase-e", "z2-stepgen-phase-f",
  613. "charge-pump-out","cp-dir","cp-pc","cp-pd","cp-fe","cp-pf"]
  614. human_stepper_names = [ [_("Unused StepGen"),[]],[_("X Axis StepGen"),[]],[_("Y Axis StepGen"),[]],[_("Z Axis StepGen"),[]],
  615. [_("A Axis StepGen"),[]],[_("Spindle StepGen"),[]],[_("X2 Tandem StepGen"),[]],[_("Y2 Tandem StepGen"),[]],
  616. [_("Z2 Tandem StepGen"),[]],[_("Charge Pump StepGen"),[]],[_("Custom Signals"),[]] ]
  617. (UNUSED_TPPWM,
  618. X_TPPWM_A, X_TPPWM_B,X_TPPWM_C,X_TPPWM_AN,X_TPPWM_BN,X_TPPWM_CN,X_TPPWM_ENABLE,X_TPPWM_FAULT,
  619. Y_TPPWM_A, Y_TPPWM_B,Y_TPPWM_C,Y_TPPWM_AN,Y_TPPWM_BN,Y_TPPWM_CN,Y_TPPWM_ENABLE,Y_TPPWM_FAULT,
  620. Z_TPPWM_A, Z_TPPWM_B,Z_TPPWM_C,Z_TPPWM_AN,Z_TPPWM_BN,Z_TPPWM_CN,Z_TPPWM_ENABLE,Z_TPPWM_FAULT,
  621. A_TPPWM_A, A_TPPWM_B,A_TPPWM_C,A_TPPWM_AN,A_TPPWM_BN,A_TPPWM_CN,A_TPPWM_ENABLE,A_TPPWM_FAULT,
  622. S_TPPWM_A, S_TPPWM_B,S_TPPWM_C,S_TPPWM_AN,S_TPPWM_BN,S_TPPWM_CN,S_TPPWM_ENABLE,S_TPPWM_FAULT) = hal_tppwm_output_names= ["unused-tppwm",
  623. "x-tppwm-a","x-tppwm-b","x-tppwm-c","x-tppwm-anot","x-tppwm-bnot","x-tppwm-cnot", "x-tppwm-enable","x-tppwm-fault",
  624. "y-tppwm-a","y-tppwm-b","y-tppwm-c","y-tppwm-anot","y-tppwm-bnot","y-tppwm-cnot", "y-tppwm-enable","y-tppwm-fault",
  625. "z-tppwm-a","z-tppwm-b","z-tppwm-c","z-tppwm-anot","z-tppwm-bnot","z-tppwm-cnot", "z-tppwm-enable","z-tppwm-fault",
  626. "a-tppwm-a","a-tppwm-b","a-tppwm-c","a-tppwm-anot","a-tppwm-bnot","a-tppwm-cnot", "a-tppwm-enable","a-tppwm-fault",
  627. "s-tppwm-a","s-tppwm-b","s-tppwm-c","s-tppwm-anot","s-tppwm-bnot","s-tppwm-cnot", "s-tppwm-enable","s-tppwm-fault"]
  628. human_tppwm_output_names = [ [_("Unused TPPWM Gen"),[]],[_("X Axis BL Driver"),[]],[ _("Y Axis BL Driver"),[]],
  629. [_("Z Axis BL Driver"),[]],[_("A Axis BL Driver"),[]],[_("S Axis BL Driver"),[]],[_("Custom Signals"),[]] ]
  630. (UNUSED_SSERIAL,A8I20_T,A8I20_R,A8I20_E,I7I64_T,I7I64_R,I7I64_E,I7I69_T,I7I69_R,I7I69_E,
  631. I7I70_T,I7I70_R,I7I70_E,I7I71_T,I7I71_R,I7I71_E,I7I76_M0_T,I7I76_M0_R,I7I76_M0_E,
  632. I7I77_M0_T,I7I77_M0_R,I7I77_M0_E,I7I73_M0_T,I7I73_M0_R,I7I73_M0_E) = hal_sserial_names = ["unused-sserial",
  633. "8i20-t","8i20-r","8i20-e","7i64-t","7i64-r","7i64-e","7i69-t","7i69-r","7i69-e","7i70-t","7i70-r","7i70-e",
  634. "7i71-t","7i71-r","7i71-e","7i76-m0-t","7i76-m0-r","7i76-m0-e", "7i77-m0-t","7i77-m0-r","7i77-m0-e", "7i73-m1-t","7i73-m1-r","7i73-m1-e"]
  635. human_sserial_names = [ [_("Unused Channel"),[]],[_("8i20 Amplifier Card"),[]],[ _("7i64 I/O Card"),[]],[ _("7i69 I/O Card"),[]],
  636. [ _("7i70 I/O Card"),[]],[ _("7i71 I/O Card"),[]],[ _("7i76 Mode 0 I/O Card"),[]],[ _("7i77 Mode 0 I/O Card"),[]],
  637. [ _("7i73 Mode 1 Pendant Card"),[]] ]
  638. (UNUSED_ANALOG_IN) = hal_analog_input_names = ["unused-analog-input"]
  639. human_analog_input_names = [ [_("Unused Analog In"),[]],[_("Custom Signals"),[]] ]
  640. prefs = preferences.preferences()
  641. def dbg(message,mtype):
  642. for hint in _DEBUGSTRING:
  643. if hint == "all" or hint in mtype:
  644. print(message)
  645. if "step" in _DEBUGSTRING:
  646. c = raw_input("\n**** Debug Pause! ****")
  647. return
  648. def md5sum(filename):
  649. try:
  650. f = open(filename, "rb")
  651. except IOError:
  652. return None
  653. else:
  654. return hashlib.md5(f.read()).hexdigest()
  655. class Widgets:
  656. def __init__(self, xml):
  657. self._xml = xml
  658. def __getattr__(self, attr):
  659. r = self._xml.get_widget(attr)
  660. if r is None: raise AttributeError, "No widget %r" % attr
  661. return r
  662. def __getitem__(self, attr):
  663. r = self._xml.get_widget(attr)
  664. if r is None: raise IndexError, "No widget %r" % attr
  665. return r
  666. class Data:
  667. def __init__(self):
  668. pw = pwd.getpwuid(os.getuid())
  669. # custom signal name lists
  670. self.halencoderinputsignames = []
  671. self.halmuxencodersignames = []
  672. self.halresolversignames = []
  673. self.hal8i20signames = []
  674. self.halpwmoutputsignames = []
  675. self.haltppwmoutputsignames = []
  676. self.halinputsignames = []
  677. self.haloutputsignames = []
  678. self.halsteppersignames = []
  679. self.halpotsignames = []
  680. self.halanaloginsignames = []
  681. # internal flags
  682. self._arrayloaded = False
  683. self._mesa0_configured = False
  684. self._mesa1_configured = False
  685. self._components_is_prepared = False
  686. # internal combobox arrays
  687. self._notusedliststore = None
  688. self._gpioliststore = None
  689. self._stepperliststore = None
  690. self._encoderliststore = None
  691. self._muxencoderliststore = None
  692. self._resolverliststore = None
  693. self._8i20liststore = None
  694. self._pwmliststore = None
  695. self._tppwmliststore = None
  696. self._sserialliststore = None
  697. self._potliststore = None
  698. self._analoginliststore = None
  699. self._gpioosignaltree = None
  700. self._gpioisignaltree = None
  701. self._steppersignaltree = None
  702. self._encodersignaltree = None
  703. self._muxencodersignaltree = None
  704. self._resolversignaltree = None
  705. self._8i20signaltree = None
  706. self._pwmcontrolsignaltree = None
  707. self._pwmrelatedsignaltree = None
  708. self._tppwmsignaltree = None
  709. self._sserialsignaltree = None
  710. self._potsignaltree = None
  711. self._analoginsignaltree = None
  712. # pncconf default options
  713. self.createsymlink = 1
  714. self.createshortcut = 0
  715. self._lastconfigname= ""
  716. self._chooselastconfig = True
  717. self._preference_version = 1.0
  718. self._pncconf_version = 3.0 # This is the actual version of this program
  719. self.pncconf_loaded_version = 3.0 # This will version number for new configs or be overwritten by a loaded file to the files version.
  720. self._re_editmode = False
  721. self._customfirmwarefilename = "~/Desktop/custom_firmware/firmware.py"
  722. self._substitution_list=[]
  723. # basic machine data
  724. self.help = "help-welcome.txt"
  725. self.machinename = _("my_LinuxCNC_machine")
  726. self.frontend = _AXIS
  727. self.axes = 0 # XYZ
  728. self.available_axes = []
  729. self.baseperiod = 50000
  730. self.servoperiod = 1000000
  731. self.units = _IMPERIAL # inch
  732. self.limitsnone = True
  733. self.limitswitch = False
  734. self.limitshared = False
  735. self.homenone = True
  736. self.homeswitch = False
  737. self.homeindex = False
  738. self.homeboth = False
  739. self.limitstype = 0
  740. self.homingtype = 0
  741. self.usbdevicename = "none"
  742. self.joystickjog = False
  743. self.joystickjograpidrate0 = 0.1
  744. self.joystickjograpidrate1 = 1.0
  745. self.joystickjograpidrate2 = 10.0
  746. self.joystickjograpidrate3 = 100.0
  747. self.joycmdrapida = ""
  748. self.joycmdrapidb = ""
  749. self.joycmdxpos = ""
  750. self.joycmdxneg = ""
  751. self.joycmdypos = ""
  752. self.joycmdyneg = ""
  753. self.joycmdzpos = ""
  754. self.joycmdzneg = ""
  755. self.joycmdapos = ""
  756. self.joycmdaneg = ""
  757. self.joycmdrapid = ""
  758. self.joycmdanalogx = ""
  759. self.joycmdanalogy = ""
  760. self.joycmdanalogz = ""
  761. self.joycmdanaloga = ""
  762. self.externaljog = False
  763. self.singlejogbuttons = False
  764. self.multijogbuttons = False
  765. self.jograpidrate = 1.0
  766. self.externalmpg = False
  767. self.guimpg = True
  768. self.multimpg = False
  769. self.sharedmpg = False
  770. self.incrselect = False
  771. self.mpgincrvalue0 = 0 # all incr-select low
  772. self.mpgincrvalue1 = .0001 # incr-select-a high
  773. self.mpgincrvalue2 = .0005 # b
  774. self.mpgincrvalue3 = .001 # ab
  775. self.mpgincrvalue4 = .005 # c
  776. self.mpgincrvalue5 = .01 # ac
  777. self.mpgincrvalue6 = .05 # bc
  778. self.mpgincrvalue7 = .1 # abc
  779. self.mpgincrvalue8 = .125 # d
  780. self.mpgincrvalue9 = .125 # ad
  781. self.mpgincrvalue10 = .125 # bd
  782. self.mpgincrvalue11 = .125 # abd
  783. self.mpgincrvalue12 = .125 # cd
  784. self.mpgincrvalue13 = .125 # acd
  785. self.mpgincrvalue14 = .125 # bcd
  786. self.mpgincrvalue15 = .125 # abcd
  787. self.mpgdebounce = True
  788. self.mpgdebouncetime = .2
  789. self.mpggraycode = False
  790. self.mpgignorefalse = False
  791. self.externalfo = False
  792. self.fo_usempg = False
  793. self.fo_useswitch = False
  794. self.foincrvalue0 = 0 # all incr-select low
  795. self.foincrvalue1 = 5 # incr-select-a high
  796. self.foincrvalue2 = 10 # b
  797. self.foincrvalue3 = 25 # ab
  798. self.foincrvalue4 = 50 # c
  799. self.foincrvalue5 = 75 # ac
  800. self.foincrvalue6 = 90 # bc
  801. self.foincrvalue7 = 100 # abc
  802. self.foincrvalue8 = 110 # d
  803. self.foincrvalue9 = 125 # ad
  804. self.foincrvalue10 = 140 # bd
  805. self.foincrvalue11 = 150 # abd
  806. self.foincrvalue12 = 165 # cd
  807. self.foincrvalue13 = 180 # acd
  808. self.foincrvalue14 = 190 # bcd
  809. self.foincrvalue15 = 200 # abcd
  810. self.fodebounce = True
  811. self.fodebouncetime = .2
  812. self.fograycode = False
  813. self.foignorefalse = False
  814. self.externalso = False
  815. self.so_usempg = False
  816. self.so_useswitch = False
  817. self.soincrvalue0 = 0 # all incr-select low
  818. self.soincrvalue1 = 5 # incr-select-a high
  819. self.soincrvalue2 = 10 # b
  820. self.soincrvalue3 = 25 # ab
  821. self.soincrvalue4 = 50 # c
  822. self.soincrvalue5 = 75 # ac
  823. self.soincrvalue6 = 90 # bc
  824. self.soincrvalue7 = 100 # abc
  825. self.soincrvalue8 = 110 # d
  826. self.soincrvalue9 = 125 # ad
  827. self.soincrvalue10 = 140 # bd
  828. self.soincrvalue11 = 150 # abd
  829. self.soincrvalue12 = 165 # cd
  830. self.soincrvalue13 = 180 # acd
  831. self.soincrvalue14 = 190 # bcd
  832. self.soincrvalue15 = 200 # abcd
  833. self.sodebounce = True
  834. self.sodebouncetime = .2
  835. self.sograycode = False
  836. self.soignorefalse = False
  837. self.externalmvo = False
  838. self.mvo_usempg = False
  839. self.mvo_useswitch = False
  840. self.mvoincrvalue0 = 0 # all incr-select low
  841. self.mvoincrvalue1 = 5 # incr-select-a high
  842. self.mvoincrvalue2 = 10 # b
  843. self.mvoincrvalue3 = 25 # ab
  844. self.mvoincrvalue4 = 50 # c
  845. self.mvoincrvalue5 = 75 # ac
  846. self.mvoincrvalue6 = 90 # bc
  847. self.mvoincrvalue7 = 100 # abc
  848. self.mvoincrvalue8 = 100 # d
  849. self.mvoincrvalue9 = 100 # ad
  850. self.mvoincrvalue10 = 100 # bd
  851. self.mvoincrvalue11 = 100 # abd
  852. self.mvoincrvalue12 = 100 # cd
  853. self.mvoincrvalue13 = 100 # acd
  854. self.mvoincrvalue14 = 100 # bcd
  855. self.mvoincrvalue15 = 100 # abcd
  856. self.mvodebounce = True
  857. self.mvodebouncetime = .2
  858. self.mvograycode = False
  859. self.mvoignorefalse = False
  860. # GUI frontend defaults
  861. self.position_offset = 1 # relative
  862. self.position_feedback = 1 # actual
  863. self.max_feed_override = 2.0 # percentage
  864. self.min_spindle_override = .5
  865. self.max_spindle_override = 1.0
  866. # These are for AXIS gui only
  867. self.default_linear_velocity = .25 # units per second
  868. self.min_linear_velocity = .01
  869. self.max_linear_velocity = 1.0
  870. self.default_angular_velocity = .25
  871. self.min_angular_velocity = .01
  872. self.max_angular_velocity = 1.0
  873. self.increments_metric = "5mm 1mm .5mm .1mm .05mm .01mm .005mm"
  874. self.increments_imperial= ".1in .05in .01in .005in .001in .0005in .0001in"
  875. self.editor = "gedit"
  876. self.geometry = "xyz"
  877. self.axisforcemax = False
  878. self.axissize = [False,0,0]
  879. self.axisposition = [False,0,0]
  880. # Touchy only
  881. self.touchysize = [False,0,0]
  882. self.touchyposition = [False,0,0]
  883. self.touchytheme = "Follow System Theme"
  884. self.touchyforcemax = False
  885. self.touchyabscolor = "default"
  886. self.touchyrelcolor = "default"
  887. self.touchydtgcolor = "default"
  888. self.touchyerrcolor = "default"
  889. # LinuxCNC assorted defaults and options
  890. self.toolchangeprompt = True
  891. self.multimpg = False
  892. self.require_homing = True
  893. self.individual_homing = False
  894. self.restore_joint_position = False
  895. self.random_toolchanger = False
  896. self.raise_z_on_toolchange = False
  897. self.allow_spindle_on_toolchange = False
  898. self.customhal = False
  899. self.usebldc = False
  900. # These components can be used by pncconf so we must keep track of them.
  901. # in case the user needs some for a custom HAL file
  902. self.userneededpid = 0
  903. self.userneededabs = 0
  904. self.userneededscale = 0
  905. self.userneededmux16 = 0
  906. self.userneededlowpass = 0
  907. self.userneededbldc = 0
  908. # pyvcp data
  909. self.pyvcp = 0 # not included
  910. self.pyvcpname = "custom.xml"
  911. self.pyvcpexist = False
  912. self.pyvcp1 = False
  913. self.pyvcpblank = True
  914. self.pyvcphaltype = 0 # no HAL connections specified
  915. self.pyvcpconnect = 1 # HAL connections allowed
  916. self.pyvcpwidth = 200
  917. self.pyvcpheight = 200
  918. self.pyvcpxpos = 0
  919. self.pyvcpypos = 0
  920. self.pyvcpposition = False
  921. self.pyvcpsize = False
  922. # gladevcp data
  923. self.gladevcp = False # not included
  924. self.gladesample = True
  925. self.gladeexists = False
  926. self.spindlespeedbar = True
  927. self.spindleatspeed = True
  928. self.maxspeeddisplay = 1000
  929. self.zerox = False
  930. self.zeroy = False
  931. self.zeroz = False
  932. self.zeroa = False
  933. self.autotouchz = False
  934. self.gladevcphaluicmds = 0
  935. self.centerembededgvcp = True
  936. self.sideembededgvcp = False
  937. self.standalonegvcp = False
  938. self.gladevcpposition = False
  939. self.gladevcpsize = False
  940. self.gladevcpforcemax = False
  941. self.gladevcpwidth = 200
  942. self.gladevcpheight = 200
  943. self.gladevcpxpos = 0
  944. self.gladevcpypos = 0
  945. self.gladevcptheme = "Follow System Theme"
  946. # classicladder data
  947. self.classicladder = 0 # not included
  948. self.digitsin = 15 # default number of pins
  949. self.digitsout = 15
  950. self.s32in = 10
  951. self.s32out = 10
  952. self.floatsin = 10
  953. self.floatsout = 10
  954. self.tempexists = 0 # not present ( a blank CL program edited through pncconf)
  955. self.laddername = "custom.clp"
  956. self.modbus = 0 # not included
  957. self.ladderhaltype = 0 # no HAL connections specified
  958. self.ladderconnect = 1 # HAL connections allowed
  959. self.ladderexist = False
  960. self.cl_haluicmds = 0
  961. self.laddertouchz = False
  962. # stepper timing data
  963. self.drivertype = "other"
  964. self.steptime = 5000
  965. self.stepspace = 5000
  966. self.dirhold = 20000
  967. self.dirsetup = 20000
  968. self.latency = 15000
  969. self.period = 25000
  970. # For parallel port
  971. self.pp1_direction = 1 # output
  972. self.ioaddr = "0x0278"
  973. self.ioaddr2 = _("Enter Address")
  974. self.pp2_direction = 0 # input
  975. self.ioaddr3 = _("Enter Address")
  976. self.pp3_direction = 0 # input
  977. self.number_pports = 0
  978. for connector in("pp1","pp2","pp3"):
  979. # initialize parport input / inv pins
  980. for i in (2,3,4,5,6,7,8,9,10,11,12,13,15):
  981. pinname ="%sIpin%d"% (connector,i)
  982. self[pinname] = UNUSED_INPUT
  983. pinname ="%sIpin%dinv"% (connector,i)
  984. self[pinname] = False
  985. # initialize parport output / inv pins
  986. for i in (1,2,3,4,5,6,7,8,9,14,16,17):
  987. pinname ="%sOpin%d"% (connector,i)
  988. self[pinname] = UNUSED_OUTPUT
  989. pinname ="%sOpin%dinv"% (connector,i)
  990. self[pinname] = False
  991. self.number_mesa = 1 # number of cards
  992. # for first mesa card
  993. self.mesa0_currentfirmwaredata = mesafirmwaredata[1]
  994. self.mesa0_boardtitle = "5i20"
  995. self.mesa0_firmware = "SVST8_4"
  996. self.mesa0_parportaddrs = "0x378"
  997. self.mesa0_isawatchdog = 1
  998. self.mesa0_pwm_frequency = 20000
  999. self.mesa0_pdm_frequency = 6000000
  1000. self.mesa0_3pwm_frequency = 20000
  1001. self.mesa0_watchdog_timeout = 10000000
  1002. self.mesa0_numof_encodergens = 4
  1003. self.mesa0_numof_resolvers = 0
  1004. self.mesa0_numof_pwmgens = 4
  1005. self.mesa0_numof_tppwmgens = 0
  1006. self.mesa0_numof_stepgens = 0
  1007. self.mesa0_numof_sserialports = 0
  1008. self.mesa0_numof_sserialchannels = 8
  1009. self.mesa0_sanity_7i29 = False
  1010. self.mesa0_sanity_7i30 = False
  1011. self.mesa0_sanity_7i33 = True
  1012. self.mesa0_sanity_7i40 = False
  1013. self.mesa0_sanity_7i48 = False
  1014. # second mesa card
  1015. self.mesa1_currentfirmwaredata = mesafirmwaredata[1]
  1016. self.mesa1_boardtitle = "5i20"
  1017. self.mesa1_firmware = "SVST8_4"
  1018. self.mesa1_parportaddrs = "0x378"
  1019. self.mesa1_isawatchdog = 1
  1020. self.mesa1_pwm_frequency = 20000
  1021. self.mesa1_pdm_frequency = 6000000
  1022. self.mesa1_3pwm_frequency = 20000
  1023. self.mesa1_watchdog_timeout = 10000000
  1024. self.mesa1_numof_encodergens = 4
  1025. self.mesa1_numof_resolvers = 0
  1026. self.mesa1_numof_pwmgens = 4
  1027. self.mesa1_numof_tppwmgens = 0
  1028. self.mesa1_numof_stepgens = 0
  1029. self.mesa1_numof_sserialports = 0
  1030. self.mesa1_numof_sserialchannels = 8
  1031. self.mesa1_sanity_7i29 = False
  1032. self.mesa1_sanity_7i30 = False
  1033. self.mesa1_sanity_7i33 = False
  1034. self.mesa1_sanity_7i40 = False
  1035. self.mesa1_sanity_7i48 = False
  1036. for boardnum in(0,1):
  1037. connector = 2
  1038. pinname ="mesa%dc%dpin"% (boardnum,connector)
  1039. self[pinname+"0"] = UNUSED_ENCODER
  1040. self[pinname+"0type"] = ENCB
  1041. self[pinname+"1"] = UNUSED_ENCODER
  1042. self[pinname+"1type"] = ENCA
  1043. self[pinname+"2"] = UNUSED_ENCODER
  1044. self[pinname+"2type"] = ENCB
  1045. self[pinname+"3"] = UNUSED_ENCODER
  1046. self[pinname+"3type"] = ENCA
  1047. self[pinname+"4"] = UNUSED_ENCODER
  1048. self[pinname+"4type"] = ENCI
  1049. self[pinname+"5"] = UNUSED_ENCODER
  1050. self[pinname+"5type"] = ENCI
  1051. self[pinname+"6"] = UNUSED_PWM
  1052. self[pinname+"6type"] = PWMP
  1053. self[pinname+"7"] = UNUSED_PWM
  1054. self[pinname+"7type"] = PWMP
  1055. self[pinname+"8"] = UNUSED_PWM
  1056. self[pinname+"8type"] = PWMD
  1057. self[pinname+"9"] = UNUSED_PWM
  1058. self[pinname+"9type"] = PWMD
  1059. self[pinname+"10"] = UNUSED_PWM
  1060. self[pinname+"10type"] = PWME
  1061. self[pinname+"11"] = UNUSED_PWM
  1062. self[pinname+"11type"] = PWME
  1063. self[pinname+"12"] = UNUSED_ENCODER
  1064. self[pinname+"12type"] = ENCB
  1065. self[pinname+"13"] = UNUSED_ENCODER
  1066. self[pinname+"13type"] = ENCA
  1067. self[pinname+"14"] = UNUSED_ENCODER
  1068. self[pinname+"14type"] = ENCB
  1069. self[pinname+"15"] = UNUSED_ENCODER
  1070. self[pinname+"15type"] = ENCA
  1071. self[pinname+"16"] = UNUSED_ENCODER
  1072. self[pinname+"16type"] = ENCI
  1073. self[pinname+"17"] = UNUSED_ENCODER
  1074. self[pinname+"17type"] = ENCI
  1075. self[pinname+"18"] = UNUSED_PWM
  1076. self[pinname+"18type"] = PWMP
  1077. self[pinname+"19"] = UNUSED_PWM
  1078. self[pinname+"19type"] = PWMP
  1079. self[pinname+"20"] = UNUSED_PWM
  1080. self[pinname+"20type"] = PWMD
  1081. self[pinname+"21"] = UNUSED_PWM
  1082. self[pinname+"21type"] = PWMD
  1083. self[pinname+"22"] = UNUSED_PWM
  1084. self[pinname+"22type"] = PWME
  1085. self[pinname+"23"] = UNUSED_PWM
  1086. self[pinname+"23type"] = PWME
  1087. for boardnum in(0,1):
  1088. for connector in(3,4,5,6,7,8,9):
  1089. # This initializes GPIO input pins
  1090. for i in range(0,16):
  1091. pinname ="mesa%dc%dpin%d"% (boardnum,connector,i)
  1092. self[pinname] = UNUSED_INPUT
  1093. pinname ="mesa%dc%dpin%dtype"% (boardnum,connector,i)
  1094. self[pinname] = GPIOI
  1095. # This initializes GPIO output pins
  1096. for i in range(16,24):
  1097. pinname ="mesa%dc%dpin%d"% (boardnum,connector,i)
  1098. self[pinname] = UNUSED_OUTPUT
  1099. pinname ="mesa%dc%dpin%dtype"% (boardnum,connector,i)
  1100. self[pinname] = GPIOO
  1101. for connector in(2,3,4,5,6,7,8,9):
  1102. # This initializes the mesa inverse pins
  1103. for i in range(0,24):
  1104. pinname ="mesa%dc%dpin%dinv"% (boardnum,connector,i)
  1105. self[pinname] = False
  1106. port = 0 #TODO up to 4 ports
  1107. for channel in range(0,5): #TODO add more sserial widgets should be 8
  1108. self["mesa%dsserial%d_%dsubboard"% (boardnum, port,channel)] = "none"
  1109. # This initializes pins
  1110. for i in range(0,_SSCOMBOLEN):
  1111. pinname ="mesa%dsserial%d_%dpin%d"% (boardnum, port,channel,i)
  1112. if i < 24:
  1113. self[pinname] = UNUSED_INPUT
  1114. else:
  1115. self[pinname] = UNUSED_OUTPUT
  1116. pinname ="mesa%dsserial%d_%dpin%dtype"% (boardnum, port,channel,i)
  1117. if i < 24:
  1118. self[pinname] = GPIOI
  1119. else:
  1120. self[pinname] = GPIOO
  1121. pinname ="mesa%dsserial%d_%dpin%dinv"% (boardnum, port,channel,i)
  1122. self[pinname] = False
  1123. # halui data
  1124. self.halui = 0 # not included
  1125. # Command list
  1126. for i in range(0,15):
  1127. pinname ="halui_cmd%s"% i
  1128. self[pinname] = ""
  1129. #HAL component command list
  1130. self.loadcompservo = []
  1131. self.addcompservo = []
  1132. self.loadcompbase = []
  1133. self.addcompbase = []
  1134. # common axis data
  1135. for temp in("x","y","z","a","s"):
  1136. self[temp+"drivertype"]= "custom"
  1137. self[temp+"steprev"]= 200
  1138. self[temp+"microstep"]= 5
  1139. self[temp+"motor_pulleydriver"]= 1
  1140. self[temp+"motor_pulleydriven"]= 1
  1141. self[temp+"motor_wormdriver"]= 1
  1142. self[temp+"motor_wormdriven"]= 1
  1143. self[temp+"encoder_pulleydriver"]= 1
  1144. self[temp+"encoder_pulleydriven"]= 1
  1145. self[temp+"encoder_wormdriver"]= 1
  1146. self[temp+"encoder_wormdriven"]= 1
  1147. self[temp+"motor_leadscrew"]= 5
  1148. self[temp+"encoder_leadscrew"]= 5
  1149. self[temp+"motor_leadscrew_tpi"]= 5
  1150. self[temp+"encoder_leadscrew_tpi"]= 5
  1151. self[temp+"encodercounts"]= 4000
  1152. self[temp+"usecomp"]= 0
  1153. self[temp+"compfilename"]= temp+"compensation"
  1154. self[temp+"comptype"]= 0
  1155. self[temp+"usebacklash"]= 0
  1156. self[temp+"backlash"]= 0
  1157. self[temp+"maxvel"]= 1.667
  1158. self[temp+"maxacc"]= 2
  1159. self[temp+"invertmotor"]= 0
  1160. self[temp+"invertencoder"]= 0
  1161. self[temp+"3pwmscale"]= 1
  1162. self[temp+"3pwmdeadtime"]= 500
  1163. self[temp+"outputscale"]= 10
  1164. self[temp+"outputminlimit"]= -10
  1165. self[temp+"outputmaxlimit"]= 10
  1166. self[temp+"maxoutput"]= 10
  1167. self[temp+"P"]= 1.0
  1168. self[temp+"I"]= 0
  1169. self[temp+"D"]= 0
  1170. self[temp+"FF0"]= 0
  1171. self[temp+"FF1"]= 0
  1172. self[temp+"FF2"]= 0
  1173. self[temp+"bias"]= 0
  1174. self[temp+"deadband"]= 0
  1175. self[temp+"steptime"]= 1000
  1176. self[temp+"stepspace"]= 1000
  1177. self[temp+"dirhold"]= 1000
  1178. self[temp+"dirsetup"]= 1000
  1179. self[temp+"minferror"]= .0005
  1180. self[temp+"maxferror"]= .005
  1181. self[temp+"homepos"]= 0
  1182. self[temp+"minlim"]= 0
  1183. self[temp+"maxlim"]= 8
  1184. self[temp+"homesw"]= 0
  1185. self[temp+"homesearchvel"]= .05
  1186. self[temp+"homelatchvel"]= .025
  1187. self[temp+"homefinalvel"]= 0
  1188. self[temp+"latchdir"]= 0
  1189. self[temp+"searchdir"]= 0
  1190. self[temp+"usehomeindex"]= 0
  1191. self[temp+"stepscale"]= 0
  1192. self[temp+"encoderscale"]= 0
  1193. self[temp+"bldc_option"]= False
  1194. self[temp+"bldc_config"]= ""
  1195. self[temp+"bldc_no_feedback"]= False
  1196. self[temp+"bldc_absolute_feedback"]= False
  1197. self[temp+"bldc_incremental_feedback"]= True
  1198. self[temp+"bldc_use_hall"]= True
  1199. self[temp+"bldc_use_encoder"]= False
  1200. self[temp+"bldc_fanuc_alignment"]= False
  1201. self[temp+"bldc_use_index"]= False
  1202. self[temp+"bldc_digital_output"]= False
  1203. self[temp+"bldc_six_outputs"]= False
  1204. self[temp+"bldc_force_trapz"]= False
  1205. self[temp+"bldc_emulated_feedback"]= False
  1206. self[temp+"bldc_output_hall"]= False
  1207. self[temp+"bldc_output_fanuc"]= False
  1208. self[temp+"bldc_scale"]= 512
  1209. self[temp+"bldc_poles"]= 4
  1210. self[temp+"bldc_lead_angle"]= 90
  1211. self[temp+"bldc_inital_value"]= 0.2
  1212. self[temp+"bldc_encoder_offset"]= 0
  1213. self[temp+"bldc_reverse"]= False
  1214. self[temp+"bldc_drive_offset"]= 0.0
  1215. self[temp+"bldc_pattern_out"]= 25
  1216. self[temp+"bldc_pattern_in"]= 25
  1217. self[temp+"8i20maxcurrent"] = 5.0
  1218. # rotary tables need bigger limits
  1219. self.aminlim = -9999
  1220. self.amaxlim = 9999
  1221. # spindle at speed near settings
  1222. self.srpmrange = 200.0
  1223. self.snearscale = 1.00
  1224. self.sfiltergain = 1.0
  1225. self.suseatspeed = False
  1226. self.ssingleinputencoder = False
  1227. def load(self, filename, app=None, force=False):
  1228. self.pncconf_loaded_version = 0.0
  1229. def str2bool(s):
  1230. return s == 'True'
  1231. converters = {'string': str, 'float': float, 'int': int, 'bool': str2bool, 'eval': eval}
  1232. d = xml.dom.minidom.parse(open(filename, "r"))
  1233. for n in d.getElementsByTagName("property"):
  1234. name = n.getAttribute("name")
  1235. conv = converters[n.getAttribute('type')]
  1236. text = n.getAttribute('value')
  1237. setattr(self, name, conv(text))
  1238. # this loads custom signal names created by the user
  1239. # adds endings to the custom signal name when put in
  1240. # hal signal name arrays
  1241. #encoders
  1242. temp =[]; i = False
  1243. for i in self.halencoderinputsignames:
  1244. temp.append(i)
  1245. for j in(["-a","-b","-i","-m"]):
  1246. hal_encoder_input_names.append(i+j)
  1247. if i: human_encoder_input_names[4][1]= temp
  1248. #resolvers
  1249. temp = []; i = False
  1250. for i in self.halresolversignames:
  1251. temp.append(i)
  1252. hal_resolver_input_names.append(i)
  1253. if i: human_resolver_input_names[6][1]= temp
  1254. # 8I20 amplifier card
  1255. temp = []; i = False
  1256. for i in self.hal8i20signames:
  1257. temp.append(i)
  1258. hal_8i20_input_names.append(i)
  1259. if i: human_8i20_input_names[6][1]= temp
  1260. # potentiometer
  1261. temp = []; i = False
  1262. for i in self.halpotsignames:
  1263. temp.append(i)
  1264. for j in(["-output","-enable"]):
  1265. hal_pot_output_names.append(i+j)
  1266. if i: human_pot_output_names[2][1]= temp
  1267. # analog input
  1268. temp = []; i = False
  1269. for i in self.halanaloginsignames:
  1270. temp.append(i)
  1271. hal_analog_input_names.append(i)
  1272. if i: human_analog_input_names[1][1]= temp
  1273. #pwm
  1274. temp =[]; i = False
  1275. for i in self.halpwmoutputsignames:
  1276. temp.append(i)
  1277. for j in(["-pulse","-dir","-enable"]):
  1278. hal_pwm_output_names.append(i+j)
  1279. if i: human_pwm_output_names[6][1]= temp
  1280. # tppwm
  1281. temp =[]; i = False
  1282. for i in self.haltppwmoutputsignames:
  1283. temp.append(i)
  1284. for j in(["-a","-b","-c","-anot","-bnot","-cnot","-fault","-enable"]):
  1285. hal_tppwm_output_names.append(i+j)
  1286. if i: human_tppwm_output_names[2][1]= temp
  1287. # GPIO Input
  1288. temp = []; i = False
  1289. for i in self.halinputsignames:
  1290. temp.append(i)
  1291. hal_input_names.append(i)
  1292. if i: human_input_names[16][1]= temp
  1293. # GPIO Output
  1294. temp = []; i = False
  1295. for i in self.haloutputsignames:
  1296. temp.append(i)
  1297. hal_output_names.append(i)
  1298. if i: human_output_names[10][1]= temp
  1299. # steppers
  1300. temp = []; i = False
  1301. for i in self.halsteppersignames:
  1302. temp.append(i)
  1303. for j in(["-step","-dir","-c","-d","-e","-f"]):
  1304. hal_stepper_names.append(i+j)
  1305. if i: human_stepper_names[6][1]= temp
  1306. warnings = []
  1307. warnings2 = []
  1308. if self.pncconf_loaded_version < self._pncconf_version:
  1309. warnings.append(_("This configuration was saved with an earlier version of pncconf which may be incompatible.\n\
  1310. If it doesn't plainly cause an error, you still may want to save it with another name and check it. Safer to start from scratch.\n\
  1311. If you have a REALLY large config that you wish to convert to this newer version of PNConf - ask on the LinuxCNC forum - it may be possible..") )
  1312. for f, m in self.md5sums:
  1313. m1 = md5sum(f)
  1314. if m1 and m != m1:
  1315. warnings2.append(_("File %r was modified since it was written by PNCconf") % f)
  1316. if not warnings and not warnings2: return
  1317. if warnings2:
  1318. warnings.append("")
  1319. warnings.append(_("Saving this configuration file will discard configuration changes made outside PNCconf."))
  1320. if warnings:
  1321. warnings = warnings + warnings2
  1322. self.pncconf_loaded_version = self._pncconf_version
  1323. if app:
  1324. dialog = gtk.MessageDialog(app.widgets.window1,
  1325. gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
  1326. gtk.MESSAGE_WARNING, gtk.BUTTONS_OK,
  1327. "\n".join(warnings))
  1328. dialog.show_all()
  1329. dialog.run()
  1330. dialog.destroy()
  1331. else:
  1332. for para in warnings:
  1333. for line in textwrap.wrap(para, 78): print line
  1334. print
  1335. print
  1336. if force: return
  1337. response = raw_input(_("Continue? "))
  1338. if response[0] not in _("yY"): raise SystemExit, 1
  1339. def add_md5sum(self, filename, mode="r"):
  1340. self.md5sums.append((filename, md5sum(filename)))
  1341. def write_inifile(self, base):
  1342. filename = os.path.join(base, self.machinename + ".ini")
  1343. file = open(filename, "w")
  1344. print >>file, _("# Generated by PNCconf at %s") % time.asctime()
  1345. print >>file, _("# If you make changes to this file, they will be")
  1346. print >>file, _("# overwritten when you run PNCconf again")
  1347. print >>file
  1348. print >>file, "[EMC]"
  1349. print >>file, "MACHINE = %s" % self.machinename
  1350. print >>file, "DEBUG = 0"
  1351. print >>file
  1352. print >>file, "[DISPLAY]"
  1353. if self.frontend == _AXIS:
  1354. print >>file, "DISPLAY = axis"
  1355. elif self.frontend == _TKLINUXCNC:
  1356. print >>file, "DISPLAY = tklinuxcnc"
  1357. elif self.frontend == _MINI:
  1358. print >>file, "DISPLAY = mini"
  1359. elif self.frontend == _TOUCHY:
  1360. print >>file, "DISPLAY = touchy"
  1361. if self.gladevcp:
  1362. theme = self.gladevcptheme
  1363. if theme == "Follow System Theme":theme = ""
  1364. else: theme = " -t "+theme
  1365. if self.centerembededgvcp:
  1366. print >>file, "EMBED_TAB_NAME = GladeVCP"
  1367. print >>file, "EMBED_TAB_COMMAND = halcmd loadusr -Wn gladevcp gladevcp -c gladevcp%s -H gvcp_call_list.hal -x {XID} gvcp-panel.ui"%(theme)
  1368. elif self.sideembededgvcp:
  1369. print >>file, "GLADEVCP =%s -H gvcp_call_list.hal gvcp-panel.ui"%(theme)
  1370. if self.position_offset == 1: temp ="RELATIVE"
  1371. else: temp = "MACHINE"
  1372. print >>file, "POSITION_OFFSET = %s"% temp
  1373. if self.position_feedback == 1: temp ="ACTUAL"
  1374. else: temp = "COMMANDED"
  1375. print >>file, "POSITION_FEEDBACK = %s"% temp
  1376. print >>file, "MAX_FEED_OVERRIDE = %f"% self.max_feed_override
  1377. print >>file, "MAX_SPINDLE_OVERRIDE = %f"% self.max_spindle_override
  1378. print >>file, "MIN_SPINDLE_OVERRIDE = %f"% self.min_spindle_override
  1379. print >>file, "INTRO_GRAPHIC = linuxcnc.gif"
  1380. print >>file, "INTRO_TIME = 5"
  1381. print >>file, "PROGRAM_PREFIX = %s" % \
  1382. os.path.expanduser("~/linuxcnc/nc_files")
  1383. if self.pyvcp:
  1384. print >>file, "PYVCP = pyvcp-panel.xml"
  1385. # these are for AXIS GUI only
  1386. if self.units == _METRIC:
  1387. print >>file, "INCREMENTS = %s"% self.increments_metric
  1388. else:
  1389. print >>file, "INCREMENTS = %s"% self.increments_imperial
  1390. if self.axes == 2:
  1391. print >>file, "LATHE = 1"
  1392. if self.position_offset:
  1393. temp = "RELATIVE"
  1394. else:
  1395. temp = "MACHINE"
  1396. print >>file, "POSITION_OFFSET = %s"% temp
  1397. if self.position_feedback:
  1398. temp = "ACTUAL"
  1399. else:
  1400. temp = "COMMANDED"
  1401. print >>file, "POSITION_FEEDBACK = %s"% temp
  1402. print >>file, "DEFAULT_LINEAR_VELOCITY = %f"% self.default_linear_velocity
  1403. print >>file, "MAX_LINEAR_VELOCITY = %f"% self.max_linear_velocity
  1404. print >>file, "MIN_LINEAR_VELOCITY = %f"% self.min_linear_velocity
  1405. print >>file, "DEFAULT_ANGULAR_VELOCITY = %f"% self.default_angular_velocity
  1406. print >>file, "MAX_ANGULAR_VELOCITY = %f"% self.max_angular_velocity
  1407. print >>file, "MIN_ANGULAR_VELOCITY = %f"% self.min_angular_velocity
  1408. print >>file, "EDITOR = %s"% self.editor
  1409. print >>file, "GEOMETRY = %s"% self.geometry
  1410. print >>file
  1411. print >>file, "[FILTER]"
  1412. print >>file, "PROGRAM_EXTENSION = .png,.gif,.jpg Greyscale Depth Image"
  1413. print >>file, "PROGRAM_EXTENSION = .py Python Script"
  1414. print >>file, "png = image-to-gcode"
  1415. print >>file, "gif = image-to-gcode"
  1416. print >>file, "jpg = image-to-gcode"
  1417. print >>file, "py = python"
  1418. print >>file
  1419. print >>file, "[TASK]"
  1420. print >>file, "TASK = milltask"
  1421. print >>file, "CYCLE_TIME = 0.010"
  1422. print >>file
  1423. print >>file, "[RS274NGC]"
  1424. print >>file, "PARAMETER_FILE = linuxcnc.var"
  1425. #base_period = self.ideal_period()
  1426. print >>file
  1427. print >>file, "[EMCMOT]"
  1428. print >>file, "EMCMOT = motmod"
  1429. print >>file, "COMM_TIMEOUT = 1.0"
  1430. print >>file, "COMM_WAIT = 0.010"
  1431. #print >>file, "BASE_PERIOD = %d" % self.baseperiod
  1432. print >>file, "SERVO_PERIOD = %d" % self.servoperiod
  1433. print >>file
  1434. print >>file, "[HOSTMOT2]"
  1435. print >>file, "# **** This is for info only ****"
  1436. print >>file, "# DRIVER0=%s"% self.mesa0_currentfirmwaredata[_HALDRIVER]
  1437. print >>file, "# BOARD0=%s"% self.mesa0_currentfirmwaredata[_BOARDNAME]
  1438. if self.number_mesa == 2:
  1439. print >>file, "# DRIVER1=%s" % self.mesa1_currentfirmwaredata[_HALDRIVER]
  1440. print >>file, "# BOARD1=%s"% self.mesa1_currentfirmwaredata[_BOARDNAME]
  1441. if self._substitution_list:
  1442. print >>file, "# These are to ease setting custom component's parameters in a custom HAL file"
  1443. print >>file
  1444. for i,temp in enumerate(self._substitution_list):
  1445. a,b = self._substitution_list[i]
  1446. if a =="":
  1447. print >>file
  1448. else:
  1449. print >>file,"%s=%s"%(a,b)
  1450. print >>file
  1451. print >>file, "[HAL]"
  1452. print >>file, "HALUI = halui"
  1453. print >>file, "HALFILE = %s.hal" % self.machinename
  1454. print >>file, "HALFILE = custom.hal"
  1455. if self.frontend == _AXIS:
  1456. print >>file, "POSTGUI_HALFILE = postgui_call_list.hal"
  1457. print >>file, "SHUTDOWN = shutdown.hal"
  1458. print >>file
  1459. print >>file, "[HALUI]"
  1460. if self.halui == True:
  1461. for i in range(0,15):
  1462. cmd =self["halui_cmd" + str(i)]
  1463. if cmd =="": break
  1464. print >>file,"MDI_COMMAND = %s"% cmd
  1465. print >>file
  1466. print >>file, "[TRAJ]"
  1467. if self.axes == 1:
  1468. print >>file, "AXES = 4"
  1469. print >>file, "COORDINATES = X Y Z A"
  1470. print >>file, "MAX_ANGULAR_VELOCITY = %.2f" % self.amaxvel
  1471. defvel = min(60, self.amaxvel/10.)
  1472. print >>file, "DEFAULT_ANGULAR_VELOCITY = %.2f" % defvel
  1473. elif self.axes == 0:
  1474. print >>file, "AXES = 3"
  1475. print >>file, "COORDINATES = X Y Z"
  1476. else:
  1477. print >>file, "AXES = 3"
  1478. print >>file, "COORDINATES = X Z"
  1479. if self.units == _METRIC:
  1480. print >>file, "LINEAR_UNITS = mm"
  1481. else:
  1482. print >>file, "LINEAR_UNITS = inch"
  1483. print >>file, "ANGULAR_UNITS = degree"
  1484. print >>file, "CYCLE_TIME = 0.010"
  1485. if self.axes == 2:
  1486. maxvel = max(self.xmaxvel, self.zmaxvel)
  1487. else:
  1488. maxvel = max(self.xmaxvel, self.ymaxvel, self.zmaxvel)
  1489. hypotvel = (self.xmaxvel**2 + self.ymaxvel**2 + self.zmaxvel**2) **.5
  1490. defvel = min(maxvel, max(.1, maxvel/10.))
  1491. print >>file, "DEFAULT_VELOCITY = %.2f" % defvel
  1492. print >>file, "MAX_LINEAR_VELOCITY = %.2f" % maxvel
  1493. if self.restore_joint_position:
  1494. print >>file, "POSITION_FILE = position.txt"
  1495. if not self.require_homing:
  1496. print >>file, "NO_FORCE_HOMING = 1"
  1497. print >>file
  1498. print >>file, "[EMCIO]"
  1499. print >>file, "EMCIO = io"
  1500. print >>file, "CYCLE_TIME = 0.100"
  1501. print >>file, "TOOL_TABLE = tool.tbl"
  1502. if self.allow_spindle_on_toolchange:
  1503. print >>file, "TOOL_CHANGE_WITH_SPINDLE_ON = 1"
  1504. if self.raise_z_on_toolchange:
  1505. print >>file, "TOOL_CHANGE_QUILL_UP = 1"
  1506. if self.random_toolchanger:
  1507. print >>file, "RANDOM_TOOLCHANGER = 1"
  1508. all_homes = self.home_sig("x") and self.home_sig("z")
  1509. if self.axes != 2: all_homes = all_homes and self.home_sig("y")
  1510. if self.axes == 4: all_homes = all_homes and self.home_sig("a")
  1511. self.write_one_axis(file, 0, "x", "LINEAR", all_homes)
  1512. if self.axes != 2:
  1513. self.write_one_axis(file, 1, "y", "LINEAR", all_homes)
  1514. self.write_one_axis(file, 2, "z", "LINEAR", all_homes)
  1515. if self.axes == 1:
  1516. self.write_one_axis(file, 3, "a", "ANGULAR", all_homes)
  1517. self.write_one_axis(file, 9, "s", "null", all_homes)
  1518. file.close()
  1519. self.add_md5sum(filename)
  1520. def write_one_axis(self, file, num, letter, type, all_homes):
  1521. order = "1203"
  1522. def get(s): return self[letter + s]
  1523. pwmgen = self.pwmgen_sig(letter)
  1524. tppwmgen = self.tppwmgen_sig(letter)
  1525. stepgen = self.stepgen_sig(letter)
  1526. encoder = self.encoder_sig(letter)
  1527. resolver = self.resolver_sig(letter)
  1528. potoutput = self.potoutput_sig(letter)
  1529. closedloop = False
  1530. if stepgen and (encoder or resolver): closedloop = True
  1531. if (encoder or resolver) and (pwmgen or tppwmgen) : closedloop = True
  1532. if closedloop and letter == "s": closedloop = False
  1533. #print "INI ",letter + " is closedloop? "+ str(closedloop),encoder,pwmgen,tppwmgen,stepgen
  1534. print >>file
  1535. print >>file, "#********************"
  1536. if letter == 's':
  1537. print >>file, "# Spindle "
  1538. print >>file, "#********************"
  1539. print >>file, "[SPINDLE_%d]" % num
  1540. else:
  1541. print >>file, "# Axis %s" % letter.upper()
  1542. print >>file, "#********************"
  1543. print >>file, "[AXIS_%d]" % num
  1544. print >>file, "TYPE = %s" % type
  1545. print >>file, "HOME = %s" % get("homepos")
  1546. print >>file, "FERROR = %s"% get("maxferror")
  1547. print >>file, "MIN_FERROR = %s" % get("minferror")
  1548. if not letter == "s" or (letter == "s" and stepgen):
  1549. print >>file, "MAX_VELOCITY = %s" % get("maxvel")
  1550. print >>file, "MAX_ACCELERATION = %s" % get("maxacc")
  1551. if encoder or resolver:
  1552. if closedloop:
  1553. print >>file, "P = %s" % get("P")
  1554. print >>file, "I = %s" % get("I")
  1555. print >>file, "D = %s" % get("D")
  1556. print >>file, "FF0 = %s" % get("FF0")
  1557. print >>file, "FF1 = %s" % get("FF1")
  1558. print >>file, "FF2 = %s" % get("FF2")
  1559. print >>file, "BIAS = %s"% get("bias")
  1560. print >>file, "DEADBAND = %s"% get("deadband")
  1561. print >>file, "MAX_OUTPUT = %s" % get("maxoutput")
  1562. if get("invertencoder"):
  1563. temp = -1
  1564. else: temp = 1
  1565. if encoder:
  1566. print >>file, "ENCODER_SCALE = %s" % (get("encoderscale") * temp)
  1567. else:
  1568. print >>file, "RESOLVER_SCALE = %s" % (get("encoderscale") * temp)
  1569. if pwmgen or potoutput:
  1570. if get("invertmotor"):
  1571. temp = -1
  1572. else: temp = 1
  1573. print >>file, "OUTPUT_SCALE = %s" % (get("outputscale") * temp)
  1574. pwmpinname = self.make_pinname(pwmgen)
  1575. if (pwmgen and "analog" in pwmpinname) or potoutput:
  1576. print >>file, "OUTPUT_MIN_LIMIT = %s"% (get("outputminlimit"))
  1577. print >>file, "OUTPUT_MAX_LIMIT = %s"% (get("outputmaxlimit"))
  1578. if stepgen:
  1579. print >>file, "# these are in nanoseconds"
  1580. print >>file, "DIRSETUP = %d"% int(get("dirsetup"))
  1581. print >>file, "DIRHOLD = %d"% int(get("dirhold"))
  1582. print >>file, "STEPLEN = %d"% int(get("steptime"))
  1583. print >>file, "STEPSPACE = %d"% int(get("stepspace"))
  1584. if get("invertmotor"):
  1585. temp = -1
  1586. else: temp = 1
  1587. print >>file, "STEP_SCALE = %s"% (get("stepscale") * temp)
  1588. if letter == 's':return
  1589. if self[letter + "usecomp"]:
  1590. print >>file, "COMP_FILE = %s" % get("compfilename")
  1591. print >>file, "COMP_FILE_TYPE = %s" % get("comptype")
  1592. if self[letter + "usebacklash"]:
  1593. print >>file, "BACKLASH = %s" % get("backlash")
  1594. # linuxcnc doesn't like having home right on an end of travel,
  1595. # so extend the travel limit by up to .01in or .1mm
  1596. minlim = -abs(get("minlim"))
  1597. maxlim = get("maxlim")
  1598. home = get("homepos")
  1599. if self.units == _METRIC: extend = .01
  1600. else: extend = .001
  1601. minlim = min(minlim, home - extend)
  1602. maxlim = max(maxlim, home + extend)
  1603. print >>file, "MIN_LIMIT = %s" % minlim
  1604. print >>file, "MAX_LIMIT = %s" % maxlim
  1605. thisaxishome = set(("all-home", "home-" + letter, "min-home-" + letter, "max-home-" + letter, "both-home-" + letter))
  1606. ignore = set(("min-home-" + letter, "max-home-" + letter, "both-home-" + letter))
  1607. homes = False
  1608. for i in thisaxishome:
  1609. if self.findsignal(i): homes = True
  1610. # set homing speeds and directions
  1611. # search direction : True = positive direction
  1612. # latch direction : True = opposite direction
  1613. if homes:
  1614. searchvel = abs(get("homesearchvel"))
  1615. latchvel = abs(get("homelatchvel"))
  1616. #print get("searchdir")
  1617. if get("searchdir") == 0:
  1618. searchvel = -searchvel
  1619. if get("latchdir") == 0:
  1620. latchvel = -latchvel
  1621. else:
  1622. if get("latchdir") == 1:
  1623. latchvel = -latchvel
  1624. print >>file, "HOME_OFFSET = %f" % get("homesw")
  1625. print >>file, "HOME_SEARCH_VEL = %f" % searchvel
  1626. print >>file, "HOME_LATCH_VEL = %f" % latchvel
  1627. print >>file, "HOME_FINAL_VEL = %f" % get("homefinalvel")
  1628. if get("usehomeindex"):useindex = "YES"
  1629. else: useindex = "NO"
  1630. print >>file, "HOME_USE_INDEX = %s" % useindex
  1631. for i in ignore:
  1632. if self.findsignal(i):
  1633. print >>file, "HOME_IGNORE_LIMITS = YES"
  1634. break
  1635. if all_homes and not self.individual_homing:
  1636. print >>file, "HOME_SEQUENCE = %s" % order[num]
  1637. else:
  1638. print >>file, "HOME_OFFSET = %s" % get("homepos")
  1639. def home_sig(self, axis):
  1640. thisaxishome = set(("all-home", "home-" + axis, "min-home-" + axis, "max-home-" + axis, "both-home-" + axis))
  1641. for i in thisaxishome:
  1642. if self.findsignal(i): return i
  1643. return None
  1644. def min_lim_sig(self, axis):
  1645. thisaxishome = set(("all-limit", "min-" + axis,"min-home-" + axis, "both-" + axis, "both-home-" + axis))
  1646. for i in thisaxishome:
  1647. if self.findsignal(i): return i
  1648. return None
  1649. def max_lim_sig(self, axis):
  1650. thisaxishome = set(("all-limit", "max-" + axis, "max-home-" + axis, "both-" + axis, "both-home-" + axis))
  1651. for i in thisaxishome:
  1652. if self.findsignal(i): return i
  1653. return None
  1654. def stepgen_sig(self, axis):
  1655. thisaxisstepgen = axis + "-stepgen-step"
  1656. test = self.findsignal(thisaxisstepgen)
  1657. return test
  1658. def stepgen_invert_pins(self,pinnumber):
  1659. # sample pinname = mesa0c0pin11
  1660. signallist = []
  1661. pin = int(pinnumber[10:])
  1662. connector = int(pinnumber[6:7])
  1663. boardnum = int(pinnumber[4:5])
  1664. channel = None
  1665. pinlist = self.list_related_pins([STEPA,STEPB], boardnum, connector, channel, pin, 0)
  1666. #print pinlist
  1667. for i in pinlist:
  1668. if self[i[0]+"inv"]:
  1669. gpioname = self.make_pinname(self.findsignal( self[i[0]] ),True)
  1670. #print gpioname
  1671. signallist.append(gpioname)
  1672. return signallist
  1673. def spindle_invert_pins(self,pinnumber):
  1674. # sample pinname = mesa0sserial0_0pin11
  1675. signallist = []
  1676. pin = int(pinnumber[18:])
  1677. port = int(pinnumber[12:13])
  1678. boardnum = int(pinnumber[4:5])
  1679. channel = int(pinnumber[14:15])
  1680. pinlist = self.list_related_pins([POTO,POTE], boardnum, port, channel, pin, 0)
  1681. for i in pinlist:
  1682. if self[i[0]+"inv"]:
  1683. name = self[i[0]+"type"]
  1684. signallist.append(name)
  1685. return signallist
  1686. def encoder_sig(self, axis):
  1687. thisaxisencoder = axis +"-encoder-a"
  1688. test = self.findsignal(thisaxisencoder)
  1689. return test
  1690. def resolver_sig(self, axis):
  1691. thisaxisresolver = axis +"-resolver"
  1692. test = self.findsignal(thisaxisresolver)
  1693. return test
  1694. def amp_8i20_sig(self, axis):
  1695. thisaxis8i20 = "%s-8i20"% axis
  1696. test = self.findsignal(thisaxis8i20)
  1697. return test
  1698. def potoutput_sig(self,axis):
  1699. thisaxispot = "%s-pot-output"% axis
  1700. test = self.findsignal(thisaxispot)
  1701. return test
  1702. def pwmgen_sig(self, axis):
  1703. thisaxispwmgen = axis + "-pwm-pulse"
  1704. test = self.findsignal( thisaxispwmgen)
  1705. return test
  1706. def pwmgen_invert_pins(self,pinnumber):
  1707. print "list pwm invert pins",pinnumber
  1708. # sample pinname = mesa0c0pin11
  1709. signallist = []
  1710. pin = int(pinnumber[10:])
  1711. connector = int(pinnumber[6:7])
  1712. boardnum = int(pinnumber[4:5])
  1713. channel = None
  1714. pinlist = self.list_related_pins([PWMP, PWMD, PWME], boardnum, connector, channel, pin, 0)
  1715. print pinlist
  1716. for i in pinlist:
  1717. if self[i[0]+"inv"]:
  1718. gpioname = self.make_pinname(self.findsignal( self[i[0]] ),True)
  1719. print gpioname
  1720. signallist.append(gpioname)
  1721. return signallist
  1722. def tppwmgen_sig(self, axis):
  1723. thisaxispwmgen = axis + "-tppwm-a"
  1724. test = self.findsignal(thisaxispwmgen)
  1725. return test
  1726. def tppwmgen_has_6(self, axis):
  1727. thisaxispwmgen = axis + "-tppwm-anot"
  1728. test = self.findsignal(thisaxispwmgen)
  1729. return test
  1730. def connect_axis(self, file, num, let):
  1731. axnum = "xyzabcuvws".index(let)
  1732. title = 'AXIS'
  1733. if let == 's':
  1734. title = 'SPINDLE'
  1735. closedloop = False
  1736. pwmpin = self.pwmgen_sig(let)
  1737. pwmpinname = self.make_pinname(pwmpin)
  1738. if pwmpinname and not 'serial' in pwmpin: # TODO allow sserial PWM to be inverted
  1739. pwminvertlist = self.pwmgen_invert_pins(pwmpin)
  1740. if not pwmpin == None:
  1741. pwmtype = self.pwmgen_sig(let)+"type"
  1742. else:
  1743. pwmtype = None
  1744. tppwmpinname = self.make_pinname(self.tppwmgen_sig(let))
  1745. tppwm_six = self.tppwmgen_has_6(let)
  1746. steppinname = self.make_pinname(self.stepgen_sig(let))
  1747. steppinname2 = self.make_pinname(self.stepgen_sig(let+"2"))
  1748. bldc_control = self[let+"bldc_option"]
  1749. if steppinname:
  1750. stepinvertlist = self.stepgen_invert_pins(self.stepgen_sig(let))
  1751. if steppinname2:
  1752. stepinvertlist2 = self.stepgen_invert_pins(self.stepgen_sig(let+"2"))
  1753. encoderpinname = self.make_pinname(self.encoder_sig(let))
  1754. amp8i20pinname = self.make_pinname(self.amp_8i20_sig(let))
  1755. resolverpinname = self.make_pinname(self.resolver_sig(let))
  1756. potpinname = self.make_pinname(self.potoutput_sig(let))
  1757. if potpinname:
  1758. potinvertlist = self.spindle_invert_pins(self.potoutput_sig(let))
  1759. if steppinname and encoderpinname and not let == 's': closedloop = True
  1760. if (encoderpinname or resolverpinname) and (pwmpinname or tppwmpinname or amp8i20pinname): closedloop = True
  1761. if let == "s": closedloop = False
  1762. print let + " is closedloop? "+ str(closedloop)
  1763. print " ENCODER:",encoderpinname," RESOLVER:",resolverpinname
  1764. print " PWM:",pwmpinname," 3PWM:",tppwmpinname," 8i20:",amp8i20pinname
  1765. print " STEPPER:",steppinname, "STEPPER2:",steppinname2
  1766. print " POTENTIOMETER:",potpinname
  1767. lat = self.latency
  1768. print >>file, "#*******************"
  1769. print >>file, "# %s %s" % (title, let.upper())
  1770. print >>file, "#*******************"
  1771. print >>file
  1772. if bldc_control:
  1773. bldc = self[let+"bldc_config"]
  1774. print >>file, "# -- BLDC setup --"
  1775. print >>file, "setp bldc.%d.drive-offset %d" % (axnum,self[let+"bldc_drive_offset"])
  1776. print >>file, "setp bldc.%s.rev %d" % (axnum,self[let+"bldc_reverse"])
  1777. if "q" in(bldc):
  1778. print >>file, "setp bldc.%d.scale %d" % (axnum,self[let+"bldc_scale"])
  1779. print >>file, "setp bldc.%d.poles %d" % (axnum,self[let+"bldc_poles"])
  1780. if "i" in(bldc):
  1781. print >>file, "setp bldc.%s.initvalue %d" % (axnum,self[let+"bldc_inital_value"])
  1782. if "i" in(bldc) or "a" in(bldc):
  1783. print >>file, "setp bldc.%s.lead-angle %d" % (axnum,self[let+"bldc_lead_angle"])
  1784. print >>file, "setp bldc.%d.encoder-offset %d" % (axnum,self[let+"bldc_encoder_offset"])
  1785. if "h" in(bldc):
  1786. print >>file, "setp bldc.%d.pattern %d" % (axnum,self[let+"bldc_pattern_in"])
  1787. print >>file, "net %s-hall1-in bldc.%d.hall1"% (let,axnum)
  1788. print >>file, "net %s-hall2-in bldc.%d.hall2"% (let,axnum)
  1789. print >>file, "net %s-hall3-in bldc.%d.hall3"% (let,axnum)
  1790. if "f" in(bldc):
  1791. print >>file, "net %s-c1-in bldc.%d.C1"% (let,axnum)
  1792. print >>file, "net %s-c2-in bldc.%d.C2"% (let,axnum)
  1793. print >>file, "net %s-c4-in bldc.%d.C4"% (let,axnum)
  1794. print >>file, "net %s-c8-in bldc.%d.C8"% (let,axnum)
  1795. if "H" in(bldc):
  1796. print >>file, "setp bldc.%d.output-pattern %d" % (axnum,self[let+"bldc_pattern_out"])
  1797. print >>file, "net %s-hall1-out bldc.%d.hall1-out"% (let,axnum)
  1798. print >>file, "net %s-hall2-out bldc.%d.hall2-out"% (let,axnum)
  1799. print >>file, "net %s-hall3-out bldc.%d.hall3-out"% (let,axnum)
  1800. if "6" in(bldc) :
  1801. if "B" in(bldc):
  1802. print >>file, "net %s-a-high-on bldc.%d.A-high-on"% (let,axnum)
  1803. print >>file, "net %s-a-low-on bldc.%d.A-low-on"% (let,axnum)
  1804. print >>file, "net %s-b-high-on bldc.%d.B-high-on"% (let,axnum)
  1805. print >>file, "net %s-b-low-on bldc.%d.B-low-on"% (let,axnum)
  1806. print >>file, "net %s-c-high-on bldc.%d.C-high-on"% (let,axnum)
  1807. print >>file, "net %s-c-low-on bldc.%d.C-low-on"% (let,axnum)
  1808. else:
  1809. print >>file, "net %s-a-high-value bldc.%d.A-high"% (let,axnum)
  1810. print >>file, "net %s-a-low-value bldc.%d.A-low"% (let,axnum)
  1811. print >>file, "net %s-b-high-value bldc.%d.B-high"% (let,axnum)
  1812. print >>file, "net %s-b-low-value bldc.%d.B-low"% (let,axnum)
  1813. print >>file, "net %s-c-high-value bldc.%d.C-high"% (let,axnum)
  1814. print >>file, "net %s-c-low-value bldc.%d.C-low"% (let,axnum)
  1815. elif "B" in(bldc):
  1816. print >>file, "net %s-a-on bldc.%d.A-on"% (let,axnum)
  1817. print >>file, "net %s-b-on bldc.%d.B-on"% (let,axnum)
  1818. print >>file, "net %s-c-on bldc.%d.C-on"% (let,axnum)
  1819. elif "F" in(bldc):
  1820. print >>file, "net %s-c1-out bldc.%d.C1-out"% (let,axnum)
  1821. print >>file, "net %s-c2-out bldc.%d.C2-out"% (let,axnum)
  1822. print >>file, "net %s-c4-out bldc.%d.C4-out"% (let,axnum)
  1823. print >>file, "net %s-c8-out bldc.%d.C8-out"% (let,axnum)
  1824. else:
  1825. print >>file, "net %s-a-value bldc.%d.A-value"% (let,axnum)
  1826. print >>file, "net %s-b-value bldc.%d.B-value"% (let,axnum)
  1827. print >>file, "net %s-c-value bldc.%d.C-value"% (let,axnum)
  1828. print >>file
  1829. print >>file, "net %s-pos-rawcounts bldc.%d.rawcounts"% (let,axnum)
  1830. print >>file, "net %s-index-enable bldc.%d.index-enable"% (let,axnum)
  1831. print >>file, "net %s-bldc-current bldc.%d.out"% (let,axnum)
  1832. print >>file, "net %s-meas-angle bldc.%d.phase-angle"% (let,axnum)
  1833. print >>file, "net %s-output bldc.%d.value"% (let,axnum)
  1834. print >>file, "net %s-enable bldc.%d.init"% (let,axnum)
  1835. print >>file, "net %s-is-init bldc.%s.init-done"% (let,axnum)
  1836. print >>file
  1837. if closedloop:
  1838. print >>file, "setp pid.%s.Pgain [%s_%d]P" % (let, title, axnum)
  1839. print >>file, "setp pid.%s.Igain [%s_%d]I" % (let, title, axnum)
  1840. print >>file, "setp pid.%s.Dgain [%s_%d]D" % (let, title, axnum)
  1841. print >>file, "setp pid.%s.bias [%s_%d]BIAS" % (let, title, axnum)
  1842. print >>file, "setp pid.%s.FF0 [%s_%d]FF0" % (let, title, axnum)
  1843. print >>file, "setp pid.%s.FF1 [%s_%d]FF1" % (let, title, axnum)
  1844. print >>file, "setp pid.%s.FF2 [%s_%d]FF2" % (let, title, axnum)
  1845. print >>file, "setp pid.%s.deadband [%s_%d]DEADBAND" % (let, title, axnum)
  1846. print >>file, "setp pid.%s.maxoutput [%s_%d]MAX_OUTPUT" % (let, title, axnum)
  1847. print >>file
  1848. if let == 's':
  1849. name = "spindle"
  1850. else:
  1851. name = let
  1852. print >>file, "net %s-index-enable <=> pid.%s.index-enable" % (name, let)
  1853. print >>file, "net %s-enable => pid.%s.enable" % (name, let)
  1854. print >>file, "net %s-output => pid.%s.output"% (name, let)
  1855. if let == 's':
  1856. print >>file, "net %s-vel-cmd => pid.%s.command" % (name, let)
  1857. print >>file, "net %s-vel-fb => pid.%s.feedback"% (name, let)
  1858. else:
  1859. print >>file, "net %s-pos-cmd => pid.%s.command" % (name, let)
  1860. print >>file, "net %s-vel-fb => pid.%s.feedback-deriv"% (name, let)
  1861. print >>file, "net %s-pos-fb => pid.%s.feedback"% (name,let)
  1862. print >>file
  1863. if tppwmpinname:
  1864. print >>file, "# ---TPPWM Generator signals/setup---"
  1865. if tppwm_six:
  1866. print >>file, "# six output 3pwg"
  1867. else:print >>file, "# three output 3pwg"
  1868. print >>file, "# TODO write some commands!"
  1869. print >>file
  1870. if amp8i20pinname:
  1871. print >>file, "# ---8i20 amplifier card signals/setup---"
  1872. print >>file
  1873. print >>file, "setp %s.max_current %.3f"% (amp8i20pinname,self[let+"8i20maxcurrent"])
  1874. print >>file, "net %s-meas-angle => %s.angle"% (let,amp8i20pinname)
  1875. print >>file, "net %s-bldc-current => %s.current"% (let,amp8i20pinname)
  1876. print >>file, "net %s-enable => %s.amp_enable"% (let,amp8i20pinname)
  1877. print >>file
  1878. if potpinname:
  1879. # sserial digital potentiometer outputs for spindle eg 7i76 board
  1880. print >>file, "# ---digital potentionmeter output signals/setup---"
  1881. print >>file
  1882. print >>file, "setp "+potpinname+"spinout-minlim [%s_%d]OUTPUT_MIN_LIMIT"% (title, axnum)
  1883. print >>file, "setp "+potpinname+"spinout-maxlim [%s_%d]OUTPUT_MAX_LIMIT"% (title, axnum)
  1884. print >>file, "setp "+potpinname+"spinout-scalemax [%s_%d]OUTPUT_SCALE"% (title, axnum)
  1885. for i in potinvertlist:
  1886. if i == POTO:
  1887. print >>file, "setp "+potpinname+"spindir-invert true"
  1888. if i == POTE:
  1889. print >>file, "setp "+potpinname+"spinena-invert true"
  1890. print >>file
  1891. if closedloop:
  1892. print >>file, "net spindle-output => " + potpinname + "spinout"
  1893. else:
  1894. print >>file, "net spindle-vel-cmd => " + potpinname + "spinout"
  1895. print >>file, "net machine-is-enabled => " + potpinname +"spinena"
  1896. print >>file, "net spindle-ccw => " + potpinname +"spindir"
  1897. print >>file
  1898. if pwmpinname:
  1899. print >>file, "# ---PWM Generator signals/setup---"
  1900. print >>file
  1901. # sserial daughter board PWMGENS eg 7i77
  1902. if "analogout" in pwmpinname:
  1903. rawpinname = self.make_pinname(pwmpin,False,True) # dont want the component name
  1904. print >>file, "setp "+pwmpinname+"-scalemax [%s_%d]OUTPUT_SCALE"% (title, axnum)
  1905. print >>file, "setp "+pwmpinname+"-minlim [%s_%d]OUTPUT_MIN_LIMIT"% (title, axnum)
  1906. print >>file, "setp "+pwmpinname+"-maxlim [%s_%d]OUTPUT_MAX_LIMIT"% (title, axnum)
  1907. print >>file
  1908. if let == 's':
  1909. print >>file
  1910. if closedloop:
  1911. print >>file, "net spindle-output => " + pwmpinname
  1912. print >>file, "net machine-is-enabled => " + rawpinname + "spinena"
  1913. else:
  1914. print >>file, "net spindle-vel-cmd => " + pwmpinname
  1915. print >>file, "net machine-is-enabled => " + rawpinname + "spinena"
  1916. else:
  1917. print >>file, "net %s-output => "% (let) + pwmpinname
  1918. print >>file, "net %s-pos-cmd axis.%d.motor-pos-cmd" % (let, axnum )
  1919. print >>file, "net %s-enable axis.%d.amp-enable-out"% (let,axnum)
  1920. if let == "x":
  1921. print >>file, "# enable _all_ sserial pwmgens"
  1922. print >>file, "net %s-enable %sanalogena"% (let,rawpinname)
  1923. print >>file
  1924. else:
  1925. # mainboard PWMGENS
  1926. pulsetype = 1
  1927. if self[pwmtype] == PDMP: pulsetype = 3
  1928. if self[pwmtype] == UDMU: pulsetype = 2
  1929. print >>file, "setp "+pwmpinname+".output-type %d"% pulsetype
  1930. print >>file, "setp "+pwmpinname+".scale [%s_%d]OUTPUT_SCALE"% (title, axnum)
  1931. for i in pwminvertlist:
  1932. print >>file, "setp "+i+".invert_output true"
  1933. print >>file
  1934. if let == 's':
  1935. print >>file
  1936. if closedloop:
  1937. print >>file, "net spindle-output => " + pwmpinname + ".value"
  1938. print >>file, "net machine-is-enabled => " + pwmpinname +".enable"
  1939. else:
  1940. print >>file, "net spindle-vel-cmd => " + pwmpinname + ".value"
  1941. print >>file, "net machine-is-enabled => " + pwmpinname +".enable"
  1942. else:
  1943. print >>file, "net %s-output => "% (let) + pwmpinname + ".value"
  1944. print >>file, "net %s-pos-cmd axis.%d.motor-pos-cmd" % (let, axnum )
  1945. print >>file, "net %s-enable axis.%d.amp-enable-out => "% (let,axnum) + pwmpinname +".enable"
  1946. print >>file
  1947. if steppinname:
  1948. print >>file, "# Step Gen signals/setup"
  1949. print >>file
  1950. print >>file, "setp " + steppinname + ".dirsetup [%s_%d]DIRSETUP"% (title, axnum)
  1951. print >>file, "setp " + steppinname + ".dirhold [%s_%d]DIRHOLD"% (title, axnum)
  1952. print >>file, "setp " + steppinname + ".steplen [%s_%d]STEPLEN"% (title, axnum)
  1953. print >>file, "setp " + steppinname + ".stepspace [%s_%d]STEPSPACE"% (title, axnum)
  1954. print >>file, "setp " + steppinname + ".position-scale [%s_%d]STEP_SCALE"% (title, axnum)
  1955. print >>file, "setp " + steppinname + ".step_type 0"
  1956. if closedloop or let == "s":
  1957. print >>file, "setp " + steppinname + ".control-type 1"
  1958. else:
  1959. print >>file, "setp " + steppinname + ".control-type 0"
  1960. if let =="s":
  1961. print >>file, "setp " + steppinname + ".maxaccel [%s_%d]MAX_ACCELERATION"% (title, axnum)
  1962. print >>file, "setp " + steppinname + ".maxvel [%s_%d]MAX_VELOCITY"% (title, axnum)
  1963. else:
  1964. print >>file, "setp " + steppinname + ".maxaccel %.1f"%( (self[let+"maxacc"]*1.25) )
  1965. print >>file, "setp " + steppinname + ".maxvel %.1f"%( (self[let+"maxvel"]*1.25) )
  1966. for i in stepinvertlist:
  1967. print >>file, "setp "+i+".invert_output true"
  1968. if let == "s":
  1969. print >>file
  1970. print >>file, "net machine-is-enabled => " + steppinname + ".enable"
  1971. print >>file, "net spindle-vel-cmd-rps => "+ steppinname + ".velocity-cmd"
  1972. if not encoderpinname and not resolverpinname:
  1973. print >>file, "net spindle-vel-fb <= "+ steppinname + ".velocity-fb"
  1974. elif closedloop:
  1975. print >>file
  1976. print >>file, "# ---closedloop stepper signals---"
  1977. print >>file
  1978. print >>file, "net %s-pos-cmd axis.%d.motor-pos-cmd" % (let, axnum )
  1979. print >>file, "net %s-output => "% (let) + steppinname + ".velocity-cmd"
  1980. print >>file, "net %s-enable axis.%d.amp-enable-out => "% (let,axnum) + steppinname +".enable"
  1981. else:
  1982. print >>file
  1983. print >>file, "net %s-pos-fb axis.%d.motor-pos-fb <= "% (let, axnum) + steppinname + ".position-fb"
  1984. print >>file, "net %s-pos-cmd axis.%d.motor-pos-cmd => "% (let, axnum) + steppinname + ".position-cmd"
  1985. print >>file, "net %s-enable axis.%d.amp-enable-out => "% (let, axnum) + steppinname + ".enable"
  1986. print >>file
  1987. if steppinname2:
  1988. steppinname = steppinname2
  1989. print >>file, "# Step Gen signals/setup for tandem axis stepper"
  1990. print >>file
  1991. print >>file, "setp " + steppinname + ".dirsetup [%s_%d]DIRSETUP"% (title, axnum)
  1992. print >>file, "setp " + steppinname + ".dirhold [%s_%d]DIRHOLD"% (title, axnum)
  1993. print >>file, "setp " + steppinname + ".steplen [%s_%d]STEPLEN"% (title, axnum)
  1994. print >>file, "setp " + steppinname + ".stepspace [%s_%d]STEPSPACE"% (title, axnum)
  1995. print >>file, "setp " + steppinname + ".position-scale [%s_%d]STEP_SCALE"% (title, axnum)
  1996. print >>file, "setp " + steppinname + ".step_type 0"
  1997. if closedloop:
  1998. print >>file, "setp " + steppinname + ".control-type 1"
  1999. else:
  2000. print >>file, "setp " + steppinname + ".control-type 0"
  2001. print >>file, "setp " + steppinname + ".maxaccel %.1f"%( (self[let+"maxacc"]*1.25) )
  2002. print >>file, "setp " + steppinname + ".maxvel %.1f"%( (self[let+"maxvel"]*1.25) )
  2003. for i in stepinvertlist2:
  2004. print >>file, "setp "+i+".invert_output true"
  2005. if closedloop:
  2006. print >>file
  2007. print >>file, "# ---closedloop stepper signals---"
  2008. print >>file
  2009. print >>file, "net %s-output => "% (let) + steppinname + ".velocity-cmd"
  2010. print >>file, "net %s-enable => "% (let) + steppinname +".enable"
  2011. else:
  2012. print >>file
  2013. print >>file, "net %s2-pos-fb <= " % (let) + steppinname + ".position-fb"
  2014. print >>file, "net %s-pos-cmd => " % (let) + steppinname + ".position-cmd"
  2015. print >>file, "net %s-enable => " % (let)+ steppinname + ".enable"
  2016. print >>file
  2017. if encoderpinname:
  2018. countmode = 0
  2019. if let == "s" and self.ssingleinputencoder: countmode = 1
  2020. print >>file, "# ---Encoder feedback signals/setup---"
  2021. print >>file
  2022. print >>file, "setp "+encoderpinname+".counter-mode %d"% countmode
  2023. print >>file, "setp "+encoderpinname+".filter 1"
  2024. print >>file, "setp "+encoderpinname+".index-invert 0"
  2025. print >>file, "setp "+encoderpinname+".index-mask 0"
  2026. print >>file, "setp "+encoderpinname+".index-mask-invert 0"
  2027. print >>file, "setp "+encoderpinname+".scale [%s_%d]ENCODER_SCALE"% (title, axnum)
  2028. print >>file
  2029. if let == 's':
  2030. print >>file, "net spindle-revs <= " + encoderpinname + ".position"
  2031. print >>file, "net spindle-vel-fb <= " + encoderpinname + ".velocity"
  2032. print >>file, "net spindle-index-enable <=> " + encoderpinname + ".index-enable"
  2033. else:
  2034. print >>file, "net %s-pos-fb <= "% (let) + encoderpinname+".position"
  2035. print >>file, "net %s-vel-fb <= "% (let) + encoderpinname + ".velocity"
  2036. print >>file, "net %s-pos-fb => axis.%d.motor-pos-fb" % (let, axnum)
  2037. print >>file, "net %s-index-enable axis.%d.index-enable <=> "% (let, axnum) + encoderpinname + ".index-enable"
  2038. print >>file, "net %s-pos-rawcounts <= "% (let) + encoderpinname + ".rawcounts"
  2039. print >>file
  2040. if resolverpinname:
  2041. print >>file, "# ---Resolver feedback signals/setup---"
  2042. print >>file
  2043. print >>file, "setp "+resolverpinname+".velocity-scale 1 # mptor speed in RPS"
  2044. print >>file, "setp "+resolverpinname+".scale [%s_%d]RESOLVER_SCALE"% (title, axnum)
  2045. print >>file
  2046. print >>file, "net %s-pos-rawcounts <= "% (let) + resolverpinname + ".rawcounts"
  2047. if let == 's':
  2048. print >>file, "net spindle-revs <= " + resolverpinname + ".position"
  2049. print >>file, "net spindle-vel-fb <= " + resolverpinname + ".velocity"
  2050. print >>file, "net spindle-index-enable <=> " + resolverpinname + ".index-enable"
  2051. else:
  2052. print >>file, "net %s-pos-fb <= "% (let) + resolverpinname+".position"
  2053. print >>file, "net %s-vel-fb <= "% (let) + resolverpinname + ".velocity"
  2054. print >>file, "net %s-pos-fb => axis.%d.motor-pos-fb" % (let, axnum)
  2055. print >>file, "net %s-index-enable axis.%d.index-enable <=> "% (let, axnum) + resolverpinname + ".index-enable"
  2056. print >>file
  2057. if let =='s':
  2058. print >>file, "# ---setup spindle control signals---"
  2059. print >>file
  2060. print >>file, "net spindle-vel-cmd-rps <= motion.spindle-speed-out-rps"
  2061. print >>file, "net spindle-vel-cmd <= motion.spindle-speed-out"
  2062. print >>file, "net spindle-on <= motion.spindle-on"
  2063. print >>file, "net spindle-cw <= motion.spindle-forward"
  2064. print >>file, "net spindle-ccw <= motion.spindle-reverse"
  2065. print >>file, "net spindle-brake <= motion.spindle-brake"
  2066. print >>file, "net spindle-revs => motion.spindle-revs"
  2067. print >>file, "net spindle-at-speed => motion.spindle-at-speed"
  2068. print >>file, "net spindle-vel-fb => motion.spindle-speed-in"
  2069. print >>file, "net spindle-index-enable <=> motion.spindle-index-enable"
  2070. print >>file
  2071. if not self.findsignal("spindle-at-speed"):
  2072. print >>file, "# ---Setup spindle at speed signals---"
  2073. print >>file
  2074. if (encoderpinname or resolverpinname) and self.suseatspeed:
  2075. print >>file, "net spindle-vel-cmd-rps => near.0.in1"
  2076. print >>file, "net spindle-vel-fb => near.0.in2"
  2077. print >>file, "net spindle-at-speed <= near.0.out"
  2078. print >>file, "setp near.0.scale %f"% self.snearscale
  2079. print >>file, "setp near.0.difference %f"% (self.srpmrange/60)
  2080. print >>file
  2081. else:
  2082. print >>file, "sets spindle-at-speed true"
  2083. print >>file
  2084. if (self.pyvcp and self.pyvcphaltype == 1 and self.pyvcpconnect) or (self.gladevcp and self.spindlespeedbar):
  2085. if encoderpinname or resolverpinname:
  2086. print >>file, _("# Use ACTUAL spindle velocity from spindle encoder")
  2087. print >>file, _("# spindle-velocity bounces around so we filter it with lowpass")
  2088. print >>file, _("# spindle-velocity is signed so we use absolute component to remove sign")
  2089. print >>file, _("# ACTUAL velocity is in RPS not RPM so we scale it.")
  2090. print >>file
  2091. print >>file, ("setp scale.spindle.gain 60")
  2092. print >>file, ("setp lowpass.spindle.gain %f"% self.sfiltergain)
  2093. print >>file, ("net spindle-vel-fb => lowpass.spindle.in")
  2094. print >>file, ("net spindle-fb-filtered-rps lowpass.spindle.out => abs.spindle.in")
  2095. print >>file, ("net spindle-fb-filtered-abs-rps abs.spindle.out => scale.spindle.in")
  2096. print >>file, ("net spindle-fb-filtered-abs-rpm scale.spindle.out")
  2097. else:
  2098. print >>file, _("# Use COMMANDED spindle velocity from LinuxCNC because no spindle encoder was specified")
  2099. print >>file, _("# COMMANDED velocity is signed so we use absolute component to remove sign")
  2100. print >>file
  2101. print >>file, ("net spindle-vel-cmd => abs.spindle.in")
  2102. print >>file, ("net absolute-spindle-vel <= abs.spindle.out")
  2103. return
  2104. min_limsig = self.min_lim_sig(let)
  2105. if not min_limsig: min_limsig = "%s-neg-limit" % let
  2106. max_limsig = self.max_lim_sig(let)
  2107. if not max_limsig: max_limsig = "%s-pos-limit" % let
  2108. homesig = self.home_sig(let)
  2109. if not homesig: homesig = "%s-home-sw" % let
  2110. print >>file, "# ---setup home / limit switch signals---"
  2111. print >>file
  2112. print >>file, "net %s => axis.%d.home-sw-in" % (homesig, axnum)
  2113. print >>file, "net %s => axis.%d.neg-lim-sw-in" % (min_limsig, axnum)
  2114. print >>file, "net %s => axis.%d.pos-lim-sw-in" % (max_limsig, axnum)
  2115. print >>file
  2116. def connect_input(self, file):
  2117. print >>file, "# external input signals"
  2118. def write_pins(pname,p,i,t):
  2119. # for input pins
  2120. if t == GPIOI:
  2121. if not p == "unused-input":
  2122. pinname = self.make_pinname(pname)
  2123. print >>file, "\n# ---",p.upper(),"---"
  2124. if "parport" in pinname:
  2125. if i: print >>file, "net %s <= %s-not" % (p, pinname)
  2126. else: print >>file, "net %s <= %s" % (p, pinname)
  2127. elif "sserial" in pname:
  2128. if "7i64" in pinname:
  2129. if i: print >>file, "net %s <= "% (p)+pinname +".in-not"
  2130. else: print >>file, "net %s <= "% (p)+pinname +".in"
  2131. else:
  2132. if i: print >>file, "net %s <= "% (p)+pinname +"-not"
  2133. else: print >>file, "net %s <= "% (p)+pinname
  2134. else:
  2135. if i: print >>file, "net %s <= "% (p)+pinname +".in_not"
  2136. else: print >>file, "net %s <= "% (p)+pinname +".in"
  2137. # for encoder pins
  2138. elif t in (ENCA,MXE0,MXE1):
  2139. if not p == "unused-encoder":
  2140. for sig in (self.halencoderinputsignames):
  2141. if p == sig+"-a":
  2142. pinname = self.make_pinname(self.findsignal( p ))
  2143. print >>file, "\n# ---",sig.upper(),"---"
  2144. print >>file, "net %s <= "% (sig+"-position")+pinname +".position"
  2145. print >>file, "net %s <= "% (sig+"-count")+pinname +".count"
  2146. print >>file, "net %s <= "% (sig+"-velocity")+pinname +".velocity"
  2147. print >>file, "net %s <= "% (sig+"-reset")+pinname +".reset"
  2148. print >>file, "net %s <= "% (sig+"-index-enable")+pinname +".index-enable"
  2149. for ending in ("counter-mode","filter","index-invert","indek-mask","index-mask-invert","scale","vel-timeout"):
  2150. title = sig + "-%s"% ending
  2151. name = pinname + ".%s"% ending
  2152. self._substitution_list.append((title.upper(),name))
  2153. self._substitution_list.append(("",""))
  2154. break
  2155. elif t in (RES0,RES1,RES2,RES3,RES4,RES5):
  2156. if not p == "unused-resolver":
  2157. for sig in (self.halresolversignames):
  2158. if p == sig:
  2159. pinname = self.make_pinname(self.findsignal( p ))
  2160. print >>file, "\n# ---",sig.upper(),"---"
  2161. print >>file, "net %s <= "% (sig+"-position")+pinname +".position"
  2162. print >>file, "net %s <= "% (sig+"-count")+pinname +".count"
  2163. print >>file, "net %s <= "% (sig+"-angle")+pinname +".angle"
  2164. print >>file, "net %s <= "% (sig+"-error")+pinname +".error"
  2165. print >>file, "net %s <= "% (sig+"-velocity")+pinname +".velocity"
  2166. print >>file, "net %s <= "% (sig+"-reset")+pinname +".reset"
  2167. print >>file, "net %s <= "% (sig+"-index-enable")+pinname +".index-enable"
  2168. for ending in ("scale","velocity-scale"):
  2169. title = sig + "-%s"% ending
  2170. name = pinname + ".%s"% ending
  2171. self._substitution_list.append((title.upper(),name))
  2172. self._substitution_list.append(("",""))
  2173. break
  2174. # for analog in pins
  2175. elif t == (ANALOGIN):
  2176. if not p == "unused-analog-input":
  2177. pinname = self.make_pinname(self.findsignal( p ))
  2178. print >>file, "\n# ---",p.upper(),"---"
  2179. print >>file, "net %s <= "% (p)+pinname
  2180. # mesa mainboards
  2181. for boardnum in range(0,int(self.number_mesa)):
  2182. for concount,connector in enumerate(self["mesa%d_currentfirmwaredata"% (boardnum)][_NUMOFCNCTRS]) :
  2183. for pin in range(0,24):
  2184. pname = 'mesa%dc%dpin%d' % (boardnum,connector, pin)
  2185. p = self['mesa%dc%dpin%d' % (boardnum,connector, pin)]
  2186. i = self['mesa%dc%dpin%dinv' % (boardnum,connector, pin)]
  2187. t = self['mesa%dc%dpin%dtype' % (boardnum,connector, pin)]
  2188. write_pins(pname,p,i,t)
  2189. # sserial
  2190. if self["mesa%d_numof_sserialports"% (boardnum)]: # only check if we have sserialports
  2191. print >>file
  2192. port = 0
  2193. for channel in range (0,self["mesa%d_currentfirmwaredata"% boardnum][_MAXSSERIALCHANNELS]):
  2194. if channel >4: break # TODO only have 5 channels worth of glade widgets
  2195. for pin in range (0,_SSCOMBOLEN):
  2196. pname = 'mesa%dsserial%d_%dpin%d' % (boardnum,port,channel,pin)
  2197. p = self['mesa%dsserial%d_%dpin%d' % (boardnum,port,channel,pin)]
  2198. i = self['mesa%dsserial%d_%dpin%dinv' % (boardnum,port,channel,pin)]
  2199. t = self['mesa%dsserial%d_%dpin%dtype' % (boardnum,port,channel,pin)]
  2200. write_pins(pname,p,i,t)
  2201. # parports
  2202. templist = ("pp1","pp2","pp3")
  2203. for j, k in enumerate(templist):
  2204. if self.number_pports < (j+1): break
  2205. print >>file
  2206. for x in (2,3,4,5,6,7,8,9,10,11,12,13,15):
  2207. pname = "%sIpin%d" % (k, x)
  2208. p = self[pname]
  2209. i = self[pname+"inv"]
  2210. if not p == "unused-input":
  2211. write_pins(pname,p,i,GPIOI)
  2212. def connect_output(self, file):
  2213. print >>file, "# external output signals"
  2214. def write_pins(pname,p,i,t,boardnum,connector,port,channel,pin):
  2215. # for output /open drain pins
  2216. if t in (GPIOO,GPIOD):
  2217. if not p == "unused-output":
  2218. pinname = self.make_pinname(pname)
  2219. print >>file, "\n# ---",p.upper(),"---"
  2220. if "parport" in pinname:
  2221. if p == "force-pin-true":
  2222. print >>file, "setp %s true"% (pinname)
  2223. else:
  2224. print >>file, "net %s %s"% (p,pinname)
  2225. else:
  2226. if "sserial" in pname:
  2227. # different sserial have different endings
  2228. if "7i64" in pinname:
  2229. temp = pinname + ".out"
  2230. else:
  2231. temp = pinname
  2232. # mainboard GPIOO require extra setup commands
  2233. else:
  2234. print >>file, "setp %s true"% (pinname + ".is_output")
  2235. if t == GPIOD: print >>file, "setp "+pinname+".is_opendrain true"
  2236. temp = pinname + ".out"
  2237. # set pin true if force-pin-true otherwise connect to a signal
  2238. if p == "force-pin-true":
  2239. print >>file, "setp %s true"% (temp)
  2240. else:
  2241. print >>file, "net %s %s"% (p,temp)
  2242. if i: # invert pin
  2243. if "sserial" in pname:
  2244. if "7i64" in pinname:
  2245. ending = ".invert"
  2246. else:
  2247. ending = "-invert"
  2248. elif "parport" in pinname: ending = "-invert"
  2249. else: ending = ".invert_output"
  2250. print >>file, "setp %s true"% (pinname + ending )
  2251. # for pwm pins
  2252. elif t in (PWMP,PDMP,UDMU):
  2253. if not p == "unused-pwm":
  2254. for sig in (self.halpwmoutputsignames):
  2255. if p == (sig+"-pulse"):
  2256. pinname = self.make_pinname(pname)
  2257. print >>file, "\n# ---",sig.upper(),"---"
  2258. if t == PWMP:
  2259. print >>file, "setp "+pinname +".output-type 1"
  2260. if t == UDMU:
  2261. print >>file, "setp "+pinname +".output-type 2"
  2262. elif t == PDMP:
  2263. print >>file, "setp "+pinname +".output-type 3"
  2264. print >>file, "net %s <= "% (sig+"-enable")+pinname +".enable"
  2265. print >>file, "net %s <= "% (sig+"-value")+pinname +".value"
  2266. for ending in ("scale","output-type"):
  2267. title = sig + "-%s"% ending
  2268. name = pinname + ".%s"% ending
  2269. self._substitution_list.append((title.upper(),name))
  2270. self._substitution_list.append(("",""))
  2271. break
  2272. # fot TP pwm pins
  2273. elif t == (TPPWMA):
  2274. if not p == "unused-tppwmgen":
  2275. for sig in (self.haltppwmoutputsignames):
  2276. if p == (sig+"-a"):
  2277. pinname = self.make_pinname(pname)
  2278. print >>file, "\n# ---",sig.upper(),"---"
  2279. print >>file, "net %s <= "% (sig+"-enable")+pinname +".enable"
  2280. print >>file, "net %s <= "% (sig+"-a-value")+pinname +".A-value"
  2281. print >>file, "net %s <= "% (sig+"-b-value")+pinname +".B-value"
  2282. print >>file, "net %s <= "% (sig+"-c-value")+pinname +".C-value"
  2283. print >>file, "net %s <= "% (sig+"-fault")+pinname +".fault"
  2284. for ending in ("scale","deadtime","fault-invert","sample-time"):
  2285. title = sig + "-%s"% ending
  2286. name = pinname + ".%s"% ending
  2287. self._substitution_list.append((title.upper(),name))
  2288. self._substitution_list.append(("",""))
  2289. break
  2290. # for stepper pins
  2291. elif t == (STEPA):
  2292. if not p == "unused-stepgen":
  2293. for sig in (self.halsteppersignames):
  2294. if p == (sig+"-step"):
  2295. pinname = self.make_pinname(pname)
  2296. print >>file, "\n# ---",sig.upper(),"---"
  2297. print >>file, "net %s <= "% (sig+"-enable")+pinname +".enable"
  2298. print >>file, "net %s <= "% (sig+"-count")+pinname +".counts"
  2299. print >>file, "net %s <= "% (sig+"-cmd-position")+pinname +".position-cmd"
  2300. print >>file, "net %s <= "% (sig+"-act-position")+pinname +".position-fb"
  2301. print >>file, "net %s <= "% (sig+"-velocity")+pinname +".velocity-fb"
  2302. pinlist = self.list_related_pins([STEPA,STEPB], boardnum, connector, channel, pin, 0)
  2303. for i in pinlist:
  2304. if self[i[0]+"inv"]:
  2305. gpioname = self.make_pinname(i[0],True)
  2306. print >>file, "setp "+gpioname+".invert_output true"
  2307. for ending in ("position-scale","maxvel","maxaccel","steplen","stepspace","dirsetup","dirhold","step_type"):
  2308. title = sig + "-%s"% ending
  2309. name = pinname + ".%s"% ending
  2310. self._substitution_list.append((title.upper(),name))
  2311. self._substitution_list.append(("",""))
  2312. break
  2313. # potentiometer outpot
  2314. elif t == (POTO):
  2315. print pname
  2316. if not p == "unused-pot":
  2317. for sig in (self.halpotsignames):
  2318. print "looking",p,sig
  2319. if p == (sig+"-output"):
  2320. pinname = self.make_pinname(pname)
  2321. print >>file, "\n# ---",sig.upper(),"---"
  2322. print >>file, "net %s => "% (sig+"-enable")+pinname +".spinena"
  2323. print >>file, "net %s => "% (sig+"-output")+pinname +".spinout"
  2324. print >>file, "net %s => "% (sig+"-direction")+pinname +".spindir"
  2325. pinlist = self.list_related_pins([POTO,POTE], boardnum, port, channel, pin, 0)
  2326. for i in pinlist:
  2327. if self[i[0]+"inv"]:
  2328. if self[i[0]+"type"] == POTO:
  2329. print >>file, "setp "+pinname+".spindir-invert true"
  2330. if self[i[0]+"type"] == POTE:
  2331. print >>file, "setp "+pinname+".spinena-invert true"
  2332. for ending in ("spindir-invert","spinena-invert","spinout-maxlim","spinout-minlim","spinout-scalemax"):
  2333. title = sig + "-%s"% ending
  2334. name = pinname + ".%s"% ending
  2335. self._substitution_list.append((title.upper(),name))
  2336. self._substitution_list.append(("",""))
  2337. break
  2338. # mesa mainboards
  2339. for boardnum in range(0,int(self.number_mesa)):
  2340. for concount,connector in enumerate(self["mesa%d_currentfirmwaredata"% (boardnum)][_NUMOFCNCTRS]) :
  2341. for pin in range(0,24):
  2342. pname = 'mesa%dc%dpin%d' % (boardnum,connector, pin)
  2343. p = self['mesa%dc%dpin%d' % (boardnum,connector, pin)]
  2344. i = self['mesa%dc%dpin%dinv' % (boardnum,connector, pin)]
  2345. t = self['mesa%dc%dpin%dtype' % (boardnum,connector, pin)]
  2346. write_pins(pname,p,i,t,boardnum,connector,None,None,pin)
  2347. # mesa sserial
  2348. if self["mesa%d_numof_sserialports"% (boardnum)]: # only check if we have sserialports
  2349. print >>file
  2350. port = 0
  2351. for channel in range (0,self["mesa%d_currentfirmwaredata"% boardnum][_MAXSSERIALCHANNELS]):
  2352. if channel >4: break # TODO only have 5 channels worth of glade widgets
  2353. for pin in range (0,_SSCOMBOLEN):
  2354. pname = 'mesa%dsserial%d_%dpin%d' % (boardnum,port,channel,pin)
  2355. p = self['mesa%dsserial%d_%dpin%d' % (boardnum,port,channel,pin)]
  2356. i = self['mesa%dsserial%d_%dpin%dinv' % (boardnum,port,channel,pin)]
  2357. t = self['mesa%dsserial%d_%dpin%dtype' % (boardnum,port,channel,pin)]
  2358. write_pins(pname,p,i,t,boardnum,None,port,channel,pin)
  2359. # parports
  2360. templist = ("pp1","pp2","pp3")
  2361. for j, k in enumerate(templist):
  2362. if self.number_pports < (j+1): break
  2363. print >>file
  2364. for x in (1,2,3,4,5,6,7,8,9,14,16,17):
  2365. pname = "%sOpin%d" % (k, x)
  2366. p = self[pname]
  2367. i = self[pname+"inv"]
  2368. if not p == "unused-output":
  2369. write_pins(pname,p,i,GPIOO,None,None,None,None,None)
  2370. def write_halfile(self, base):
  2371. def writebackup(origname):
  2372. path, ext = os.path.splitext(origname)
  2373. name = path.replace(base+"/","")
  2374. print base
  2375. print path,name,ext
  2376. shutil.copy(origname ,os.path.join(base,"backups",name + str(time.time()).replace('.', '') + ext) )
  2377. self._substitution_list = []
  2378. axis_convert = ("x","y","z","a")
  2379. halui_cmd_count = 0
  2380. filename = os.path.join(base, self.machinename + ".hal")
  2381. file = open(filename, "w")
  2382. print >>file, _("# Generated by PNCconf at %s") % time.asctime()
  2383. print >>file, _("# If you make changes to this file, they will be")
  2384. print >>file, _("# overwritten when you run PNCconf again")
  2385. print >>file
  2386. if self.pyvcp and not self.frontend == _AXIS:
  2387. size = pos = geo = ""
  2388. if self.pyvcpposition or self.pyvcpsize:
  2389. if self.pyvcpposition:
  2390. pos = "+%d+%d"% (self.pyvcpxpos,self.pyvcpypos)
  2391. if self.pyvcpsize:
  2392. size = "%dx%d"% (self.pyvcpwidth,self.pyvcpheight)
  2393. geo = " -g %s%s"%(size,pos)
  2394. print >>file, "loadusr -Wn pyvcp pyvcp%s -c pyvcp [DISPLAY](PYVCP)"%(geo)
  2395. print >>file, "source postgui_call_list.hal"
  2396. if self.gladevcp and self.standalonegvcp:
  2397. fmax = geo = pos = size = ""
  2398. if self.gladevcpposition or self.gladevcpsize:
  2399. if self.gladevcpposition:
  2400. pos = "+%d+%d"% (self.gladevcpxpos,self.gladevcpypos)
  2401. if self.gladevcpsize:
  2402. size = "%dx%d"% (self.gladevcpwidth,self.gladevcpheight)
  2403. geo = " -g %s%s"%(size,pos)
  2404. if self.gladevcpforcemax: fmax = " -m True"
  2405. theme = self.gladevcptheme
  2406. if theme == "Follow System Theme":theme = ""
  2407. else: theme = " -t "+theme
  2408. print >>file, "loadusr -Wn gladevcp gladevcp -c gladevcp%s%s%s -H gvcp_call_list.hal gvcp-panel.ui"%(theme,fmax,geo)
  2409. print >>file, "loadrt trivkins"
  2410. print >>file, "loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES"
  2411. print >>file, "loadrt probe_parport"
  2412. print >>file, "loadrt hostmot2"
  2413. board0 = self.mesa0_currentfirmwaredata[_BOARDNAME]
  2414. board1 = self.mesa1_currentfirmwaredata[_BOARDNAME]
  2415. driver0 = self.mesa0_currentfirmwaredata[_HALDRIVER]
  2416. driver1 = self.mesa1_currentfirmwaredata[_HALDRIVER]
  2417. directory0 = self.mesa0_currentfirmwaredata[_DIRECTORY]
  2418. directory1 = self.mesa1_currentfirmwaredata[_DIRECTORY]
  2419. firm0 = self.mesa0_currentfirmwaredata[_FIRMWARE]
  2420. firm1 = self.mesa1_currentfirmwaredata[_FIRMWARE]
  2421. # TODO fix this hardcoded hack: only one serial port
  2422. ssconfig0 = ssconfig1 = resolver0 = resolver1 = temp = ""
  2423. if self.mesa0_numof_resolvers:
  2424. resolver0 = "num_resolvers=%d"% self.mesa0_numof_resolvers
  2425. if self.mesa1_numof_resolvers:
  2426. resolver1 = "num_resolvers=%d"% self.mesa1_numof_resolvers
  2427. if self.mesa0_numof_sserialports:
  2428. for i in range(1,9):
  2429. if i <= self.mesa0_numof_sserialchannels:
  2430. # if m1 in the name then it needs mode 1
  2431. if "m1" in self["mesa0sserial0_%dsubboard"% (i-1)]:
  2432. temp = temp + "1"
  2433. else:
  2434. temp = temp + "0"
  2435. else:
  2436. temp = temp + "x"
  2437. ssconfig0 = "sserial_port_0=%s"% temp
  2438. if self.mesa1_numof_sserialports:
  2439. for i in range(1,9):
  2440. if i <= self.mesa1_numof_sserialchannels:
  2441. # if m1 in the name then it needs mode 1
  2442. if "m1" in self["mesa1sserial0_%dsubboard"% (i-1)]:
  2443. temp = temp + "1"
  2444. else:
  2445. temp = temp + "0"
  2446. else:
  2447. temp = temp + "x"
  2448. ssconfig1 = "sserial_port_0=%s"% temp
  2449. firmstring0 = firmstring1 = ""
  2450. if not "5i25" in board0:
  2451. firmstring0 = "firmware=hm2/%s/%s.BIT" % (directory0, firm0)
  2452. if not "5i25" in board1:
  2453. firmstring1 = "firmware=hm2/%s/%s.BIT" % (directory1, firm1)
  2454. if self.number_mesa == 1:
  2455. print >>file, """loadrt %s config="%s num_encoders=%d num_pwmgens=%d num_3pwmgens=%d num_stepgens=%d %s %s" """ % (
  2456. driver0, firmstring0, self.mesa0_numof_encodergens, self.mesa0_numof_pwmgens, self.mesa0_numof_tppwmgens, self.mesa0_numof_stepgens ,ssconfig0, resolver0)
  2457. elif self.number_mesa == 2 and (driver0 == driver1):
  2458. print >>file, """loadrt %s config="%s num_encoders=%d num_pwmgens=%d num_3pwmgens=%d num_stepgens=%d %s %s,%s num_encoders=%d num_pwmgens=%d num_3pwmgens=%d num_stepgens=%d %s %s"
  2459. """ % ( driver0, firmstring0, self.mesa0_numof_encodergens, self.mesa0_numof_pwmgens, self.mesa0_numof_tppwmgens, self.mesa0_numof_stepgens, ssconfig0, resolver0,firmstring1, self.mesa1_numof_encodergens, self.mesa1_numof_pwmgens, self.mesa1_numof_tppwmgens, self.mesa1_numof_stepgens, ssconfig1, resolver1 )
  2460. elif self.number_mesa == 2:
  2461. print >>file, """loadrt %s config="%s num_encoders=%d num_pwmgens=%d num_3pwmgens=%d num_stepgens=%d %s %s" """ % (
  2462. driver0, firmstring0, self.mesa0_numof_encodergens, self.mesa0_numof_pwmgens, self.mesa0_numof_tppwmgens,self.mesa0_numof_stepgens, ssconfig0, resolver0 )
  2463. print >>file, """loadrt %s config="%s num_encoders=%d num_pwmgens=%d num_3pwmgens=%d num_stepgens=%d %s %s" """ % (
  2464. driver1, firmstring1, self.mesa1_numof_encodergens, self.mesa1_numof_pwmgens, self.mesa0_numof_tppwmgens,self.mesa1_numof_stepgens, ssconfig1, resolver1 )
  2465. for boardnum in range(0,int(self.number_mesa)):
  2466. if boardnum == 1 and (board0 == board1):
  2467. halnum = 1
  2468. else:
  2469. halnum = 0
  2470. if self["mesa%d_numof_pwmgens"% boardnum] > 0:
  2471. print >>file, "setp hm2_%s.%d.pwmgen.pwm_frequency %d"% ( self["mesa%d_currentfirmwaredata"% boardnum][_BOARDNAME],
  2472. halnum, self["mesa%d_pwm_frequency"% boardnum] )
  2473. print >>file, "setp hm2_%s.%d.pwmgen.pdm_frequency %d"% ( self["mesa%d_currentfirmwaredata"% boardnum][_BOARDNAME],
  2474. halnum,self["mesa%d_pdm_frequency"% boardnum] )
  2475. print >>file, "setp hm2_%s.%d.watchdog.timeout_ns %d"% ( self["mesa%d_currentfirmwaredata"% boardnum][_BOARDNAME],
  2476. halnum,self["mesa%d_watchdog_timeout"% boardnum] )
  2477. if self.number_pports>0:
  2478. port3name = port2name = port1name = port3dir = port2dir = port1dir = ""
  2479. if self.number_pports>2:
  2480. port3name = " " + self.ioaddr3
  2481. if self.pp3_direction:
  2482. port3dir =" out"
  2483. else:
  2484. port3dir =" in"
  2485. if self.number_pports>1:
  2486. port2name = " " + self.ioaddr2
  2487. if self.pp2_direction:
  2488. port2dir =" out"
  2489. else:
  2490. port2dir =" in"
  2491. port1name = self.ioaddr
  2492. if self.pp1_direction:
  2493. port1dir =" out"
  2494. else:
  2495. port1dir =" in"
  2496. print >>file, "loadrt hal_parport cfg=\"%s%s%s%s%s%s\"" % (port1name, port1dir, port2name, port2dir, port3name, port3dir)
  2497. if self.joystickjog:
  2498. print >>file, "loadusr -W hal_input -KRAL %s\n"% self.usbdevicename
  2499. spindle_enc = counter = probe = pwm = pump = estop = False
  2500. spindle_on = spindle_cw = spindle_ccw = False
  2501. mist = flood = brake = at_speed = bldc = False
  2502. if self.findsignal("s-encoder-a"):
  2503. spindle_enc = True
  2504. if self.findsignal("probe"):
  2505. probe = True
  2506. if self.findsignal("s-pwm-pulse"):
  2507. pwm = True
  2508. if self.findsignal("charge-pump"):
  2509. pump = True
  2510. if self.findsignal("estop-ext"):
  2511. estop = True
  2512. if self.findsignal("spindle-on"):
  2513. spindle_on = True
  2514. if self.findsignal("spindle-cw"):
  2515. spindle_cw = True
  2516. if self.findsignal("spindle-ccw"):
  2517. spindle_ccw = True
  2518. if self.findsignal("coolant-mist"):
  2519. mist = True
  2520. if self.findsignal("coolant-flood"):
  2521. flood = True
  2522. if self.findsignal("spindle-brake"):
  2523. brake = True
  2524. if self.findsignal("spindle-at-speed"):
  2525. at_speed = True
  2526. for i in self.available_axes:
  2527. if self[i+"bldc_option"]:
  2528. bldc = True
  2529. break
  2530. chargepump = self.findsignal("charge-pump-out")
  2531. # load PID compnent:
  2532. # if axis needs PID- (has pwm signal) then add its letter to pidlist
  2533. temp = ""
  2534. for i in self.available_axes:
  2535. #print "looking at available axis : ",i
  2536. if not self.findsignal(i+"-encoder-a") and not self.findsignal(i+"-resolver"):
  2537. continue
  2538. temp = temp + "pid.%s,"%i
  2539. # if user requested PID components add them to the list as well, starting at 0 and working up
  2540. for i in range(0,self.userneededpid):
  2541. temp=temp+"pid.%d,"% (i)
  2542. pidlist = temp.rstrip(",")
  2543. if not pidlist == "":
  2544. print >>file, "loadrt pid names=%s"% pidlist
  2545. if bldc or self.userneededbldc:
  2546. self._bldcconfigstring = ""
  2547. if bldc:
  2548. for i in self.available_axes:
  2549. temp = self[i+"bldc_config"]
  2550. #print i,temp
  2551. if temp:
  2552. self._bldcconfigstring = self._bldcconfigstring + temp + ","
  2553. if self.userneededbldc:
  2554. self._bldcconfigstring = self._bldcconfigstring + self.userneededbldc + ","
  2555. temp = self._bldcconfigstring.rstrip(",")
  2556. self._bldcconfigstring = temp
  2557. print >>file, "loadrt bldc cfg=%s"% temp
  2558. if (self.pyvcp and self.pyvcpconnect == 1) or self.gladevcp or self.userneededabs >0:
  2559. self.absnames=""
  2560. needed = False
  2561. if self.gladevcp and self.spindlespeedbar: needed = True
  2562. if self.pyvcphaltype == 1 and self.pyvcpconnect == 1 and self.pyvcp: needed = True
  2563. if needed:
  2564. self.absnames=self.absnames+"abs.spindle"
  2565. if self.userneededabs >0:
  2566. self.absnames=self.absnames+","
  2567. for i in range(0,self.userneededabs):
  2568. self.absnames = self.absnames+"abs.%d"% (i)
  2569. if i <> self.userneededabs-1:
  2570. self.absnames = self.absnames+","
  2571. print >>file, "loadrt abs names=%s"% self.absnames
  2572. if (self.pyvcp and self.pyvcpconnect == 1) or self.gladevcp or self.userneededlowpass >0:
  2573. self.lowpassnames=""
  2574. needed = False
  2575. for i in range(0,self.userneededlowpass):
  2576. self.lowpassnames = self.lowpassnames+"lowpass.%d,"% (i)
  2577. if self.pyvcphaltype == 1 and self.pyvcpconnect == 1 and self.pyvcp: needed = True
  2578. if self.gladevcp and self.spindlespeedbar: needed = True
  2579. if needed:
  2580. self.lowpassnames=self.lowpassnames+"lowpass.spindle"
  2581. temp = self.lowpassnames.rstrip(",")
  2582. self.lowpassnames = temp
  2583. print >>file, "loadrt lowpass names=%s"% temp
  2584. pytest = self.pyvcp and self.pyvcphaltype == 1 and self.pyvcpconnect == 1
  2585. gladetest = self.gladevcp and self.spindlespeedbar
  2586. self.scalenames=""
  2587. if spindle_enc and (pytest or gladetest):
  2588. self.scalenames=self.scalenames+"scale.spindle"
  2589. if self.userneededscale >0:
  2590. self.scalenames=self.scalenames+","
  2591. if self.userneededscale >0:
  2592. for i in range(0,self.userneededscale):
  2593. self.scalenames = self.scalenames+"scale.%d"% (i)
  2594. if i <> self.userneededscale-1:
  2595. self.scalenames = self.scalenames+","
  2596. if not self.scalenames == "":
  2597. print >>file, "loadrt scale names=%s"% self.scalenames
  2598. if pump:
  2599. print >>file, "loadrt charge_pump"
  2600. if not at_speed and self.suseatspeed:
  2601. print >>file, "loadrt near"
  2602. if self.classicladder:
  2603. print >>file, "loadrt classicladder_rt numPhysInputs=%d numPhysOutputs=%d numS32in=%d numS32out=%d numFloatIn=%d numFloatOut=%d" %(self.digitsin , self.digitsout , self.s32in, self.s32out, self.floatsin, self.floatsout)
  2604. if self.externalmpg or self.externalfo or self.externalmvo or self.externalso or self.joystickjog or self.userneededmux16 > 0:
  2605. self.mux16names=""
  2606. for i in range(0,self.userneededmux16):
  2607. self.mux16names = self.mux16names+"mux16.%d,"% (i)
  2608. if self.joystickjog:
  2609. self.mux16names = self.mux16names+"jogspeed,"
  2610. if self.externalmpg:
  2611. self.mux16names = self.mux16names+"jogincr,"
  2612. if self.externalfo:
  2613. self.mux16names = self.mux16names+"foincr,"
  2614. if self.externalmvo:
  2615. self.mux16names = self.mux16names+"mvoincr,"
  2616. if self.externalso:
  2617. self.mux16names = self.mux16names+"soincr,"
  2618. temp = self.mux16names.rstrip(",")
  2619. self.mux16names = temp
  2620. print >>file, "loadrt mux16 names=%s"% (self.mux16names)
  2621. # load user custom components
  2622. for i in self.loadcompbase:
  2623. if i == '': continue
  2624. else:
  2625. print >>file, i
  2626. for i in self.loadcompservo:
  2627. if i == '': continue
  2628. else:
  2629. print >>file, i
  2630. print >>file
  2631. if self.number_pports > 0:
  2632. print >>file, "addf parport.0.read servo-thread"
  2633. if self.number_pports > 1:
  2634. print >>file, "addf parport.1.read servo-thread"
  2635. if self.number_pports > 2:
  2636. print >>file, "addf parport.2.read servo-thread"
  2637. if pump: print >>file, "addf charge-pump servo-thread"
  2638. for i in self.addcompbase:
  2639. if not i == '':
  2640. print >>file, i +" base-thread"
  2641. if self.number_pports > 0:
  2642. print >>file, "addf parport.0.write servo-thread"
  2643. if self.number_pports > 1:
  2644. print >>file, "addf parport.1.write servo-thread"
  2645. if self.number_pports > 2:
  2646. print >>file, "addf parport.2.write servo-thread"
  2647. if self.number_mesa:
  2648. for boardnum in range(0,int(self.number_mesa)):
  2649. if boardnum == 1 and (self.mesa0_currentfirmwaredata[_BOARDNAME] == self.mesa1_currentfirmwaredata[_BOARDNAME]):
  2650. halnum = 1
  2651. else:
  2652. halnum = 0
  2653. if self.number_mesa> 0:
  2654. print >>file, "addf hm2_%s.%d.read servo-thread"% (self["mesa%d_currentfirmwaredata"% boardnum][_BOARDNAME], halnum)
  2655. print >>file, "addf motion-command-handler servo-thread"
  2656. print >>file, "addf motion-controller servo-thread"
  2657. if not pidlist == "":
  2658. temp = pidlist.split(",")
  2659. for i in temp:
  2660. print >>file, "addf %s.do-pid-calcs servo-thread"% i
  2661. if bldc or self.userneededbldc:
  2662. temp=self._bldcconfigstring.split(",")
  2663. for num,j in enumerate(temp):
  2664. print >>file, "addf bldc.%d servo-thread"% num
  2665. if self.classicladder:
  2666. print >>file,"addf classicladder.0.refresh servo-thread"
  2667. if self.externalmpg or self.externalfo or self.externalmvo or self.externalso or self.joystickjog or self.userneededmux16 > 0:
  2668. temp=self.mux16names.split(",")
  2669. for j in (temp):
  2670. print >>file, "addf %s servo-thread"% j
  2671. needed = False
  2672. if self.pyvcp and self.pyvcphaltype == 1 and self.pyvcpconnect == 1: needed = True
  2673. if self.userneededabs > 0 or (self.gladevcp and self.spindlespeedbar): needed = True
  2674. if needed:
  2675. temp=self.absnames.split(",")
  2676. for j in (temp):
  2677. print >>file, "addf %s servo-thread"% j
  2678. needed = False
  2679. if spindle_enc:
  2680. if self.pyvcp and self.pyvcphaltype == 1 and self.pyvcpconnect == 1: needed = True
  2681. if (self.gladevcp and self.spindlespeedbar): needed = True
  2682. if self.userneededscale > 0 or needed :
  2683. temp=self.scalenames.split(",")
  2684. for j in (temp):
  2685. print >>file, "addf %s servo-thread"% j
  2686. needed = False
  2687. if self.pyvcp and self.pyvcphaltype == 1 and self.pyvcpconnect == 1: needed = True
  2688. if self.userneededlowpass > 0 or (self.gladevcp and self.spindlespeedbar): needed = True
  2689. if needed:
  2690. temp=self.lowpassnames.split(",")
  2691. for j in (temp):
  2692. print >>file, "addf %s servo-thread"% j
  2693. for i in self.addcompservo:
  2694. if not i == '':
  2695. print >>file, i +" servo-thread"
  2696. if not at_speed and self.suseatspeed:
  2697. print >>file, "addf near.0 servo-thread"
  2698. if self.number_mesa:
  2699. for boardnum in range(0,int(self.number_mesa)):
  2700. if boardnum == 1 and (self.mesa0_currentfirmwaredata[_BOARDNAME] == self.mesa1_currentfirmwaredata[_BOARDNAME]):
  2701. halnum = 1
  2702. else:
  2703. halnum = 0
  2704. print >>file, "addf hm2_%s.%d.write servo-thread"% (self["mesa%d_currentfirmwaredata"% boardnum][_BOARDNAME], halnum)
  2705. print >>file, "addf hm2_%s.%d.pet_watchdog servo-thread"% (self["mesa%d_currentfirmwaredata"% boardnum][_BOARDNAME], halnum)
  2706. if chargepump:
  2707. steppinname = self.make_pinname(chargepump)
  2708. print >>file
  2709. print >>file, "# ---Chargepump StepGen: 0.25 velocity = 10Khz square wave output---"
  2710. print >>file
  2711. print >>file, "setp " + steppinname + ".dirsetup 100"
  2712. print >>file, "setp " + steppinname + ".dirhold 100"
  2713. print >>file, "setp " + steppinname + ".steplen 100"
  2714. print >>file, "setp " + steppinname + ".stepspace 100"
  2715. print >>file, "setp " + steppinname + ".position-scale 10000"
  2716. print >>file, "setp " + steppinname + ".step_type 2"
  2717. print >>file, "setp " + steppinname + ".control-type 1"
  2718. print >>file, "setp " + steppinname + ".maxaccel 0"
  2719. print >>file, "setp " + steppinname + ".maxvel 0"
  2720. print >>file, "setp " + steppinname + ".velocity-cmd 0.25"
  2721. print >>file
  2722. print >>file, "net x-enable => " + steppinname +".enable"
  2723. print >>file
  2724. self.connect_output(file)
  2725. print >>file
  2726. self.connect_input(file)
  2727. print >>file
  2728. if self.axes == 2:
  2729. self.connect_axis(file, 0, 'x')
  2730. self.connect_axis(file, 1, 'z')
  2731. self.connect_axis(file, 2, 's')
  2732. elif self.axes == 0:
  2733. self.connect_axis(file, 0, 'x')
  2734. self.connect_axis(file, 1, 'y')
  2735. self.connect_axis(file, 2, 'z')
  2736. self.connect_axis(file, 3, 's')
  2737. elif self.axes == 1:
  2738. self.connect_axis(file, 0, 'x')
  2739. self.connect_axis(file, 1, 'y')
  2740. self.connect_axis(file, 2, 'z')
  2741. self.connect_axis(file, 3, 'a')
  2742. self.connect_axis(file, 4, 's')
  2743. print >>file
  2744. print >>file, "#******************************"
  2745. print >>file, _("# connect miscellaneous signals")
  2746. print >>file, "#******************************"
  2747. print >>file
  2748. print >>file, _("# ---HALUI signals---")
  2749. print >>file
  2750. for axnum,axletter in enumerate(axis_convert):
  2751. if axletter in self.available_axes:
  2752. print >>file, "net joint-select-%s halui.joint.%d.select"% (chr(axnum+97),axnum)
  2753. print >>file, "net %s-is-homed halui.joint.%d.is-homed"% (axletter,axnum)
  2754. print >>file, "net jog-%s-pos halui.jog.%d.plus"% (axletter,axnum)
  2755. print >>file, "net jog-%s-neg halui.jog.%d.minus"% (axletter,axnum)
  2756. print >>file, "net jog-%s-analog halui.jog.%d.analog"% (axletter,axnum)
  2757. print >>file, "net jog-selected-pos halui.jog.selected.plus"
  2758. print >>file, "net jog-selected-neg halui.jog.selected.minus"
  2759. print >>file, "net spindle-manual-cw halui.spindle.forward"
  2760. print >>file, "net spindle-manual-ccw halui.spindle.reverse"
  2761. print >>file, "net spindle-manual-stop halui.spindle.stop"
  2762. print >>file, "net machine-is-on halui.machine.is-on"
  2763. print >>file, "net jog-speed halui.jog-speed "
  2764. print >>file, "net MDI-mode halui.mode.is-mdi"
  2765. print >>file
  2766. if pump:
  2767. print >>file, _("# ---charge pump signals---")
  2768. print >>file, "net estop-out => charge-pump.enable"
  2769. print >>file, "net charge-pump <= charge-pump.out"
  2770. print >>file
  2771. print >>file, _("# ---coolant signals---")
  2772. print >>file
  2773. print >>file, "net coolant-mist <= iocontrol.0.coolant-mist"
  2774. print >>file, "net coolant-flood <= iocontrol.0.coolant-flood"
  2775. print >>file
  2776. print >>file, _("# ---probe signal---")
  2777. print >>file
  2778. print >>file, "net probe-in => motion.probe-input"
  2779. print >>file
  2780. if self.externaljog:
  2781. print >>file, _("# ---jog button signals---")
  2782. print >>file
  2783. print >>file, "sets jog-speed %f"% self.jograpidrate
  2784. print >>file
  2785. if self.joystickjog:
  2786. print >>file, _("# ---USB device jog button signals---")
  2787. print >>file
  2788. print >>file, "# connect selectable mpg jog speeds "
  2789. print >>file, "net jog-speed-a => jogspeed.sel0"
  2790. print >>file, "net jog-speed-b => jogspeed.sel1"
  2791. print >>file, "net jog-speed <= jogspeed.out-f"
  2792. print >>file, "setp jogspeed.in00 %f"% (self.joystickjograpidrate0)
  2793. print >>file, "setp jogspeed.in01 %f"% (self.joystickjograpidrate1)
  2794. print >>file, "setp jogspeed.in02 %f"% (self.joystickjograpidrate2)
  2795. print >>file, "setp jogspeed.in03 %f"% (self.joystickjograpidrate3)
  2796. if not self.joycmdrapida =="":
  2797. print >>file, "net jog-speed-a <= %s"% (self.joycmdrapida)
  2798. if not self.joycmdrapidb =="":
  2799. print >>file, "net jog-speed-b <= %s"% (self.joycmdrapidb)
  2800. for axnum,axletter in enumerate(axis_convert):
  2801. if axletter in self.available_axes:
  2802. pin_pos = self["joycmd"+axletter+"pos"]
  2803. pin_neg = self["joycmd"+axletter+"neg"]
  2804. if not pin_pos == "" and not pin_neg =="":
  2805. print >>file, "net jog-%s-pos %s"% (axletter,pin_pos)
  2806. print >>file, "net jog-%s-neg %s"% (axletter,pin_neg)
  2807. pin_analog = self["joycmdanalog"+axletter]
  2808. if not pin_analog == "":
  2809. print >>file, "net jog-%s-analog %s"% (axletter,pin_analog)
  2810. print >>file
  2811. # check for shared MPG
  2812. pinname = self.make_pinname(self.findsignal("select-mpg-a"))
  2813. if pinname:
  2814. ending = ""
  2815. if "encoder" in pinname: ending = ".count"
  2816. print >>file, "# ---jogwheel signals to mesa encoder - shared MPG---"
  2817. print >>file
  2818. print >>file, "net joint-selected-count <= %s%s"% (pinname,ending)
  2819. if ending:
  2820. print >>file, "setp %s.filter true" % pinname
  2821. print >>file, "setp %s.counter-mode true" % pinname
  2822. print >>file
  2823. # was jogging MPG option selected?
  2824. if self.externalmpg:
  2825. print >>file, _("# ---mpg signals---")
  2826. print >>file
  2827. if not self.multimpg:
  2828. for axnum,axletter in enumerate(axis_convert):
  2829. if axletter in self.available_axes:
  2830. print >>file, "# for axis %s MPG" % (axletter)
  2831. print >>file, "setp axis.%d.jog-vel-mode 0" % axnum
  2832. print >>file, "net selected-jog-incr => axis.%d.jog-scale" % (axnum)
  2833. print >>file, "net joint-select-%s => axis.%d.jog-enable"% (chr(axnum+97),axnum)
  2834. print >>file, "net joint-selected-count => axis.%d.jog-counts"% (axnum)
  2835. print >>file
  2836. # check for dedicated axis MPG jogging option
  2837. for axnum,axletter in enumerate(axis_convert):
  2838. if axletter in self.available_axes:
  2839. pinname = self.make_pinname(self.findsignal(axletter+"-mpg-a"))
  2840. if pinname:
  2841. ending = ""
  2842. if "encoder" in pinname: ending = ".count"
  2843. print >>file, "# ---jogwheel signals to mesa encoder - %s axis MPG---"% axletter
  2844. print >>file
  2845. print >>file, "net %s-jog-count <= %s%s"% (axletter, pinname,ending)
  2846. if ending:
  2847. print >>file, "setp %s.filter true" % pinname
  2848. print >>file, "setp %s.counter-mode false" % pinname
  2849. print >>file
  2850. if self.externalmpg:
  2851. print >>file, _("# ---mpg signals---")
  2852. print >>file
  2853. if self.multimpg: # means MPG per axis
  2854. print >>file, "setp axis.%d.jog-vel-mode 0" % axnum
  2855. print >>file, "net %s-jog-enable => axis.%d.jog-enable"% (axletter, axnum)
  2856. print >>file, "net %s-jog-count => axis.%d.jog-counts" % (axletter, axnum)
  2857. print >>file, "net selected-jog-incr => axis.%d.jog-scale" % (axnum)
  2858. print >>file, "sets %s-jog-enable true"% (axletter)
  2859. print >>file
  2860. if self.externalmpg and not self.frontend == _TOUCHY:# TOUCHY GUI sets its own jog increments:
  2861. if self.incrselect :
  2862. print >>file, "# connect selectable mpg jog increments "
  2863. print >>file
  2864. print >>file, "net jog-incr-a => jogincr.sel0"
  2865. print >>file, "net jog-incr-b => jogincr.sel1"
  2866. print >>file, "net jog-incr-c => jogincr.sel2"
  2867. print >>file, "net jog-incr-d => jogincr.sel3"
  2868. print >>file, "net selected-jog-incr <= jogincr.out-f"
  2869. if self.mpgdebounce:
  2870. print >>file, " setp jogincr.debounce-time %f"% self.mpgdebouncetime
  2871. print >>file, " setp jogincr.use-graycode %s"% self.mpggraycode
  2872. print >>file, " setp jogincr.suppress-no-input %s" % self.mpgignorefalse
  2873. for i in range(0,16):
  2874. value = self["mpgincrvalue%d"% i]
  2875. print >>file, " setp jogincr.in%02d %f"% (i,value)
  2876. print >>file
  2877. else:
  2878. print >>file, "sets selected-jog-incr %f"% (self.mpgincrvalue0)
  2879. print >>file
  2880. # check for dedicated feed override MPG
  2881. pinname = self.make_pinname(self.findsignal("fo-mpg-a"))
  2882. if pinname:
  2883. ending = ""
  2884. if "encoder" in pinname: ending = ".count"
  2885. print >>file, "# ---feed override signals to mesa encoder - mpg---"
  2886. print >>file
  2887. print >>file, "net fo-count <= %s%s"% (pinname,ending)
  2888. if ending:
  2889. print >>file, "setp %s.filter true" % pinname
  2890. print >>file, "setp %s.counter-mode true" % pinname
  2891. print >>file
  2892. # was feed overrride option selected? MPG or switch selcted?
  2893. if self.externalfo:
  2894. if self.fo_usempg:
  2895. print >>file, "# connect feed overide increments - MPG"
  2896. print >>file
  2897. print >>file, " setp halui.feed-override.direct-value false"
  2898. print >>file, " setp halui.feed-override.scale .01"
  2899. if pinname: # dedicated MPG
  2900. if self.findsignal("fo-enable"): # make it enable-able externally
  2901. print >>file, "net fo-enable => halui.feed-override.count-enable"
  2902. else:
  2903. print >>file, " setp halui.feed-override.count-enable true"
  2904. print >>file, "net fo-count => halui.feed-override.counts"
  2905. else: # shared MPG
  2906. print >>file, "net fo-enable => halui.feed-override.count-enable"
  2907. print >>file, "net joint-selected-count => halui.feed-override.counts"
  2908. print >>file
  2909. elif self.fo_useswitch:
  2910. print >>file, "# connect feed overide increments - switches"
  2911. print >>file
  2912. print >>file, " setp halui.feed-override.count-enable true"
  2913. print >>file, " setp halui.feed-override.direct-value true"
  2914. print >>file, " setp halui.feed-override.scale .01"
  2915. print >>file, "net feedoverride-incr => halui.feed-override.counts"
  2916. print >>file, "net fo-incr-a => foincr.sel0"
  2917. print >>file, "net fo-incr-b => foincr.sel1"
  2918. print >>file, "net fo-incr-c => foincr.sel2"
  2919. print >>file, "net fo-incr-d => foincr.sel3"
  2920. print >>file, "net feedoverride-incr <= foincr.out-s"
  2921. if self.fodebounce:
  2922. print >>file, " setp foincr.debounce-time %f"% self.fodebouncetime
  2923. print >>file, " setp foincr.use-graycode %s"% self.fograycode
  2924. print >>file, " setp foincr.suppress-no-input %s" % self.foignorefalse
  2925. for i in range(0,16):
  2926. value = self["foincrvalue%d"% i]
  2927. print >>file, " setp foincr.in%02d %f"% (i,value)
  2928. print >>file
  2929. # check for dedicated max velocity MPG
  2930. pinname = self.make_pinname(self.findsignal("mvo-mpg-a"))
  2931. if pinname:
  2932. ending = ""
  2933. if "encoder" in pinname: ending = ".count"
  2934. print >>file, "# ---max velocity override signals to mesa encoder - mpg---"
  2935. print >>file
  2936. print >>file, "net mvo-count <= %s%s"% (pinname,ending)
  2937. if ending:
  2938. print >>file, "setp %s.filter true" % pinname
  2939. print >>file, "setp %s.counter-mode true" % pinname
  2940. print >>file
  2941. # was max velocity override option selected? MPG or switch selected?
  2942. if self.externalmvo:
  2943. temp=[]
  2944. for i in self.available_axes:
  2945. temp.append(float(self[i+"maxvel"]))
  2946. scale = max(temp)/100
  2947. if self.mvo_usempg:
  2948. print >>file, "# connect max velocity overide increments - MPG"
  2949. print >>file
  2950. print >>file, " setp halui.max-velocity.direct-value false"
  2951. print >>file, " setp halui.max-velocity.scale %04f"% scale
  2952. if pinname: # dedicated MPG
  2953. if self.findsignal("mvo-enable"): # make it enable-able externally
  2954. print >>file, "net mvo-enable => halui.max-velocity.count-enable"
  2955. else:
  2956. print >>file, " setp halui.max-velocity.count-enable true"
  2957. print >>file, "net mvo-count => halui.max-velocity.counts"
  2958. else: # shared MPG
  2959. print >>file, "net mvo-enable => halui.max-velocity.count-enable"
  2960. print >>file, "net joint-selected-count => halui.max-velocity.counts"
  2961. print >>file
  2962. elif self.mvo_useswitch:
  2963. print >>file, "# connect max velocity overide increments - switches"
  2964. print >>file
  2965. print >>file, " setp halui.max-velocity.count-enable true"
  2966. print >>file, " setp halui.max-velocity.direct-value true"
  2967. print >>file, " setp halui.max-velocity.scale %04f"% scale
  2968. print >>file, "net max-vel-override-incr => halui.max-velocity.counts"
  2969. print >>file, "net mvo-incr-a => mvoincr.sel0"
  2970. print >>file, "net mvo-incr-b => mvoincr.sel1"
  2971. print >>file, "net mvo-incr-c => mvoincr.sel2"
  2972. print >>file, "net mvo-incr-d => mvoincr.sel3"
  2973. print >>file, "net max-vel-override-incr <= mvoincr.out-s"
  2974. if self.mvodebounce:
  2975. print >>file, " setp mvoincr.debounce-time %f"% self.mvodebouncetime
  2976. print >>file, " setp mvoincr.use-graycode %s"% self.mvograycode
  2977. print >>file, " setp mvoincr.suppress-no-input %s" % self.mvoignorefalse
  2978. for i in range(0,16):
  2979. value = self["mvoincrvalue%d"% i]
  2980. print >>file, " setp mvoincr.in%02d %f"% (i,value)
  2981. print >>file
  2982. # check for dedicated spindle override MPG
  2983. pinname = self.make_pinname(self.findsignal("so-mpg-a"))
  2984. if pinname:
  2985. ending = ""
  2986. if "encoder" in pinname: ending = ".count"
  2987. print >>file, "# ---spindle override signals to mesa encoder - mpg---"
  2988. print >>file
  2989. print >>file, "net so-count <= %s%s"% (pinname,ending)
  2990. if ending:
  2991. print >>file, "setp %s.filter true" % pinname
  2992. print >>file, "setp %s.counter-mode true" % pinname
  2993. print >>file
  2994. if self.externalso:
  2995. if self.so_usempg:
  2996. print >>file, "# connect spindle overide increments - MPG"
  2997. print >>file
  2998. print >>file, " setp halui.spindle-override.direct-value false"
  2999. print >>file, " setp halui.spindle-override.scale .01"
  3000. if pinname: # dedicated MPG
  3001. if self.findsignal("so-enable"): # make it enable-able externally
  3002. print >>file, "net so-enable => halui.spindle-override.count-enable"
  3003. else:
  3004. print >>file, " setp halui.spindle-override.count-enable true"
  3005. print >>file, "net so-count => halui.spindle-override.counts"
  3006. else: # shared MPG
  3007. print >>file, "net so-enable => halui.spindle-override.count-enable"
  3008. print >>file, "net joint-selected-count => halui.spindle-override.counts"
  3009. print >>file
  3010. elif self.so_useswitch:
  3011. print >>file, "# connect spindle overide increments "
  3012. print >>file
  3013. print >>file, " setp halui.spindle-override.count-enable true"
  3014. print >>file, " setp halui.spindle-override.direct-value true"
  3015. print >>file, " setp halui.spindle-override.scale .01"
  3016. print >>file, "net spindleoverride-incr => halui.spindle-override.counts"
  3017. print >>file, "net so-incr-a => soincr.sel0"
  3018. print >>file, "net so-incr-b => soincr.sel1"
  3019. print >>file, "net so-incr-c => soincr.sel2"
  3020. print >>file, "net so-incr-d => soincr.sel3"
  3021. print >>file, "net spindleoverride-incr <= soincr.out-s"
  3022. if self.sodebounce:
  3023. print >>file, " setp soincr.debounce-time %f"% self.sodebouncetime
  3024. print >>file, " setp soincr.use-graycode %s"% self.sograycode
  3025. print >>file, " setp soincr.suppress-no-input %s" % self.soignorefalse
  3026. for i in range(0,16):
  3027. value = self["soincrvalue%d"% i]
  3028. print >>file, " setp soincr.in%02d %f"% (i,value)
  3029. print >>file
  3030. print >>file, _("# ---motion control signals---")
  3031. print >>file
  3032. print >>file, "net in-position <= motion.in-position"
  3033. print >>file, "net machine-is-enabled <= motion.motion-enabled"
  3034. print >>file
  3035. print >>file, _("# ---digital in / out signals---")
  3036. print >>file
  3037. for i in range(4):
  3038. dout = "dout-%02d" % i
  3039. if self.findsignal(dout):
  3040. print >>file, "net %s <= motion.digital-out-%02d" % (dout, i)
  3041. for i in range(4):
  3042. din = "din-%02d" % i
  3043. if self.findsignal(din):
  3044. print >>file, "net %s => motion.digital-in-%02d" % (din, i)
  3045. print >>file, _("# ---estop signals---")
  3046. print >>file
  3047. print >>file, "net estop-out <= iocontrol.0.user-enable-out"
  3048. if self.classicladder and self.ladderhaltype == 1 and self.ladderconnect: # external estop program
  3049. print >>file
  3050. print >>file, _("# **** Setup for external estop ladder program -START ****")
  3051. print >>file
  3052. print >>file, "net estop-out => classicladder.0.in-00"
  3053. print >>file, "net estop-ext => classicladder.0.in-01"
  3054. print >>file, "net estop-strobe classicladder.0.in-02 <= iocontrol.0.user-request-enable"
  3055. print >>file, "net estop-outcl classicladder.0.out-00 => iocontrol.0.emc-enable-in"
  3056. print >>file
  3057. print >>file, _("# **** Setup for external estop ladder program -END ****")
  3058. elif estop:
  3059. print >>file, "net estop-ext => iocontrol.0.emc-enable-in"
  3060. else:
  3061. print >>file, "net estop-out => iocontrol.0.emc-enable-in"
  3062. print >>file
  3063. if self.toolchangeprompt:
  3064. print >>file, _("# ---manual tool change signals---")
  3065. print >>file
  3066. print >>file, "loadusr -W hal_manualtoolchange"
  3067. print >>file, "net tool-change-request iocontrol.0.tool-change => hal_manualtoolchange.change"
  3068. print >>file, "net tool-change-confirmed iocontrol.0.tool-changed <= hal_manualtoolchange.changed"
  3069. print >>file, "net tool-number iocontrol.0.tool-prep-number => hal_manualtoolchange.number"
  3070. print >>file, "net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared"
  3071. print >>file
  3072. else:
  3073. print >>file, _("# ---toolchange signals for custom tool changer---")
  3074. print >>file
  3075. print >>file, "net tool-number <= iocontrol.0.tool-prep-number"
  3076. print >>file, "net tool-change-request <= iocontrol.0.tool-change"
  3077. print >>file, "net tool-change-confirmed => iocontrol.0.tool-changed"
  3078. print >>file, "net tool-prepare-request <= iocontrol.0.tool-prepare"
  3079. print >>file, "net tool-prepare-confirmed => iocontrol.0.tool-prepared"
  3080. print >>file
  3081. if self.classicladder:
  3082. print >>file
  3083. if self.modbus:
  3084. print >>file, _("# Load Classicladder with modbus master included (GUI must run for Modbus)")
  3085. print >>file
  3086. print >>file, "loadusr classicladder --modmaster custom.clp"
  3087. print >>file
  3088. else:
  3089. print >>file, _("# Load Classicladder without GUI (can reload LADDER GUI in AXIS GUI")
  3090. print >>file
  3091. print >>file, "loadusr classicladder --nogui custom.clp"
  3092. print >>file
  3093. if self.laddertouchz:
  3094. othercmds = self.gladevcphaluicmds
  3095. print >>file, _("# --- Classicladder signals for Z axis Auto touch off program---")
  3096. print >>file, "net auto-touch-z => classicladder.0.in-00"
  3097. print >>file, "net MDI-mode => classicladder.0.in-01"
  3098. print >>file, "net in-position => classicladder.0.in-02"
  3099. print >>file, "net z-touchoff-cmd classicladder.0.out-00 => halui.mdi-command-%02d"% (othercmds)
  3100. print >>file, "net z-zero-cmd classicladder.0.out-01 => halui.mdi-command-%02d"% (othercmds +1)
  3101. print >>file, "net rapid-away-cmd classicladder.0.out-02 => halui.mdi-command-%02d"% (othercmds +2)
  3102. gvcp_options_filename = os.path.join(base, "gvcp_options.hal")
  3103. gvcp_call_filename = os.path.join(base, "gvcp_call_list.hal")
  3104. if self.gladevcp:
  3105. # write the call_list
  3106. # the call_list allows multiple hal files to be loaded post gladevcp
  3107. # this simplifies the problem of overwriting the users custom HAL code
  3108. # when they change gvcp sample options
  3109. # if the user asks for existing instead of sample then if the call_list file exists
  3110. # don't overwrite it
  3111. if (not self.gladesample and not os.path.exists(gvcp_call_filename)) or self.gladesample:
  3112. f1 = open(gvcp_call_filename, "w")
  3113. print >>f1, _("# These files are loaded post gladeVCP, in the order they appear")
  3114. print >>f1
  3115. if self.gladesample:
  3116. print >>f1, "source gvcp_options.hal"
  3117. print >>f1, "source custom_gvcp.hal"
  3118. # write hal file for sample options selected
  3119. if self.gladesample:
  3120. # copy glade panel from temp file to config
  3121. gvcp = os.path.join(base, "gvcp-panel.ui")
  3122. if os.path.exists(gvcp):
  3123. writebackup(gvcp)
  3124. shutil.copy2('/tmp/gvcp-panel.ui', gvcp)
  3125. # write gvcp options HAL file
  3126. f1 = open(gvcp_options_filename, "w")
  3127. print >>f1, _("# _DO NOT_ include your HAL commands here.")
  3128. print >>f1, _("# Put custom HAL commands in custom_gvcp.hal")
  3129. print >> f1
  3130. if self.spindlespeedbar:
  3131. print >>f1, _("# **** Setup of spindle speed display using gladevcp ****")
  3132. print >>f1
  3133. if spindle_enc:
  3134. print >>f1, ("net spindle-fb-filtered-abs-rpm => gladevcp.spindle-speed")
  3135. else:
  3136. print >>f1, ("net absolute-spindle-vel => gladevcp.spindle-speed")
  3137. if self.spindleatspeed:
  3138. print >>f1, ("net spindle-at-speed => gladevcp.spindle-at-speed-led")
  3139. i = 0
  3140. print >>f1, _("# **** Setup GLADE MDI buttons ****")
  3141. print >>f1, ("net machine-is-on => gladevcp.button-box-active")
  3142. for temp in(("zerox","zero-x","x"),("zeroy","zero-y","y"),("zeroz","zero-z","z"),("zeroa","zero-a","a")):
  3143. if self[temp[0]]:
  3144. print >>f1, ("# **** MDI Command %d - %s-axis is specified in the machine named INI file under [HALUI] heading ****"%(i,temp[1]))
  3145. print >>f1, ("net MDI-%s gladevcp.%s => halui.mdi-command-%02d")%(temp[0],temp[1],i)
  3146. if self.require_homing:
  3147. print >>f1, ("net %s-is-homed => gladevcp.%s-active"% (temp[2],temp[1]))
  3148. else:
  3149. print >>f1, ("net machine-is-on => gladevcp.%s-active"% (temp[1]))
  3150. print >>f1
  3151. i += 1
  3152. if self.autotouchz:
  3153. print >>f1, _("# **** Z axis touch-off button - requires the touch-off classicladder program ****")
  3154. print >>f1, ("net auto-touch-z <= gladevcp.auto-touch-z")
  3155. print >>f1, ("net MDI-mode => gladevcp.auto-touch-z-active")
  3156. print >>f1
  3157. else:
  3158. # gvcp was not selected remove any existing related HAl files
  3159. if os.path.exists(gvcp_options_filename):
  3160. os.remove(gvcp_options_filename)
  3161. if os.path.exists(gvcp_call_filename):
  3162. os.remove(gvcp_call_filename)
  3163. if self.pyvcp:
  3164. vcp = os.path.join(base, "pyvcp-panel.xml")
  3165. if not os.path.exists(vcp):
  3166. f1 = open(vcp, "w")
  3167. print >>f1, "<?xml version='1.0' encoding='UTF-8'?>"
  3168. print >>f1, "<!-- "
  3169. print >>f1, _("Include your PyVCP panel here.\n")
  3170. print >>f1, "-->"
  3171. print >>f1, "<pyvcp>"
  3172. print >>f1, "</pyvcp>"
  3173. # the jump list allows multiple hal files to be loaded postgui
  3174. # this simplifies the problem of overwritting the users custom HAL code
  3175. # when they change pyvcp sample options
  3176. # if the user picked existing pyvcp option and the postgui_call_list is present
  3177. # don't overwrite it. otherwise write the file.
  3178. calllist_filename = os.path.join(base, "postgui_call_list.hal")
  3179. if (self.pyvcpexist and not os.path.exists(calllist_filename)) or not self.pyvcpexist:
  3180. f1 = open(calllist_filename, "w")
  3181. print >>f1, _("# These files are loaded post GUI, in the order they appear")
  3182. print >>f1
  3183. if self.pyvcp and self.pyvcphaltype == 1 and self.pyvcpconnect:
  3184. print >>f1, "source pyvcp_options.hal"
  3185. print >>f1, "source custom_postgui.hal"
  3186. # If the user asked for pyvcp sample panel add the HAL commands too
  3187. pyfilename = os.path.join(base, "pyvcp_options.hal")
  3188. if self.pyvcp and self.pyvcphaltype == 1 and self.pyvcpconnect: # spindle speed display
  3189. f1 = open(pyfilename, "w")
  3190. print >>f1, _("# _DO NOT_ include your HAL commands here.")
  3191. print >>f1, _("# Put custom HAL commands in custom_postgui.hal")
  3192. print >>f1, _("""# The commands in this file are run after the GUI loads""")
  3193. print >>f1
  3194. print >>f1, _("# **** Setup of spindle speed display using pyvcp -START ****")
  3195. print >>f1
  3196. if spindle_enc:
  3197. print >>f1, ("net spindle-fb-filtered-abs-rpm => pyvcp.spindle-speed")
  3198. else:
  3199. print >>f1, ("net absolute-spindle-vel => pyvcp.spindle-speed")
  3200. print >>f1, ("net spindle-at-speed => pyvcp.spindle-at-speed-led")
  3201. print >>f1
  3202. print >>f1, _("# **** Setup of spindle speed display using pyvcp -END ****")
  3203. print >>f1
  3204. else:
  3205. if os.path.exists(pyfilename):
  3206. os.remove(pyfilename)
  3207. # pncconf adds a custom.hal and custom_postgui.hal file if one is not present
  3208. for i in ("custom","custom_postgui","shutdown","custom_gvcp"):
  3209. custom = os.path.join(base, i+".hal")
  3210. if not os.path.exists(custom):
  3211. f1 = open(custom, "w")
  3212. print >>f1, ("# Include your %s HAL commands here")%i
  3213. print >>f1, _("# This file will not be overwritten when you run PNCconf again")
  3214. if self.frontend == _TOUCHY:# TOUCHY GUI
  3215. touchyfile = os.path.join(base, "touchy.hal")
  3216. #if not os.path.exists(touchyfile):
  3217. f1 = open(touchyfile, "w")
  3218. print >>f1, _("# These commands are required for Touchy GUI")
  3219. print >>f1, ("net cycle-start => touchy.cycle-start")
  3220. print >>f1, ("net abort => touchy.abort")
  3221. print >>f1, ("net single-step => touchy.single-block")
  3222. print >>f1, ("net selected-jog-incr <= touchy.jog.wheel.increment")
  3223. print >>f1, ("net joint-selected-count => touchy.wheel-counts")
  3224. print >>f1, ("net jog-x-pos => touchy.jog.continuous.x.positive")
  3225. print >>f1, ("net jog-x-neg => touchy.jog.continuous.x.negative")
  3226. print >>f1, ("net jog-y-pos => touchy.jog.continuous.y.positive")
  3227. print >>f1, ("net jog-y-neg => touchy.jog.continuous.y.negative")
  3228. print >>f1, ("net jog-z-pos => touchy.jog.continuous.z.positive")
  3229. print >>f1, ("net jog-z-neg => touchy.jog.continuous.z.negative")
  3230. print >>f1, ("net quillup => touchy.quill-up")
  3231. for axnum,axletter in enumerate(axis_convert):
  3232. if axletter in self.available_axes:
  3233. print >>f1, "net joint-select-%s <= touchy.jog.wheel.%s"% (chr(axnum+97), axletter)
  3234. if self.classicladder:
  3235. if not self.laddername == "custom.clp":
  3236. filename = os.path.join(distdir, "configurable_options/ladder/%s" % self.laddername)
  3237. original = os.path.expanduser("~/linuxcnc/configs/%s/custom.clp" % self.machinename)
  3238. if os.path.exists(filename): # check for the master file to copy from
  3239. if os.path.exists(original):
  3240. #print "custom file already exists"
  3241. writebackup(original)
  3242. #shutil.copy( original,os.path.expanduser("~/linuxcnc/configs/%s/backups/custom_backup.clp" % self.machinename) )
  3243. print "made backup of existing custom"
  3244. shutil.copy( filename,original)
  3245. #print "copied ladder program to usr directory"
  3246. #print"%s" % filename
  3247. else:
  3248. print "Master or temp ladder files missing from configurable_options dir"
  3249. if self.pyvcp and not self.pyvcpexist:
  3250. panelname = os.path.join(distdir, "configurable_options/pyvcp/%s" % self.pyvcpname)
  3251. originalname = os.path.expanduser("~/linuxcnc/configs/%s/pyvcp-panel.xml" % self.machinename)
  3252. if os.path.exists(panelname):
  3253. if os.path.exists(originalname):
  3254. #print "custom PYVCP file already exists"
  3255. writebackup(originalname)
  3256. #shutil.copy( originalname,os.path.expanduser("~/linuxcnc/configs/%s/backups/pyvcp-panel_backup.xml" % self.machinename) )
  3257. print "made backup of existing custom"
  3258. shutil.copy( panelname,originalname)
  3259. #print "copied PYVCP program to usr directory"
  3260. #print"%s" % panelname
  3261. else:
  3262. print "Master PYVCP file: %s missing from configurable_options dir"% self.pyvcpname
  3263. file.close()
  3264. self.add_md5sum(filename)
  3265. def write_readme(self, base):
  3266. filename = os.path.join(base, "README")
  3267. file = open(filename, "w")
  3268. print >>file, _("Generated by PNCconf at %s") % time.asctime()
  3269. print >>file
  3270. if self.units == _IMPERIAL: unit = "an imperial"
  3271. else: unit = "a metric"
  3272. if self.frontend == _AXIS: display = "AXIS"
  3273. elif self.frontend == _TKLINUXCNC: display = "Tklinuxcnc"
  3274. elif self.frontend == _MINI: display = "Mini"
  3275. elif self.frontend == _TOUCHY: display = "TOUCHY"
  3276. else: display = "an unknown"
  3277. if self.axes == 0:machinetype ="XYZ"
  3278. elif self.axes == 1:machinetype ="XYZA"
  3279. elif self.axes == 2:machinetype ="XZ-Lathe"
  3280. print >>file, self.machinename,_("configures LinuxCNC as:\n")
  3281. print >>file, unit,machinetype,_("type CNC\n")
  3282. print >>file, display,_("will be used as the frontend display")
  3283. print >>file
  3284. if self.number_mesa <> 0:
  3285. for boardnum in range(0,int(self.number_mesa)):
  3286. print >>file, "Mesa hardware I/O card - board %d is designated as\n"% boardnum,self["mesa%d_currentfirmwaredata"% boardnum][_BOARDTITLE]
  3287. print >>file, "with", self["mesa%d_currentfirmwaredata"% boardnum][_MAXGPIO], "I/O pins and firmware is:", self["mesa%d_firmware"% boardnum]
  3288. print >>file
  3289. for boardnum in range(0,int(self.number_mesa)):
  3290. for concount,connector in enumerate(self["mesa%d_currentfirmwaredata"% boardnum][_NUMOFCNCTRS]) :
  3291. print >>file,"** Mesa %s -> Board #"% self["mesa%d_boardtitle"% boardnum],boardnum,_(" connector")," %d **\n"% connector
  3292. print >>file ,"connector board num component signal "
  3293. print >>file ,"number position type name\n"
  3294. conpin = 1
  3295. for pin in range (0,24):
  3296. dummy,compnum = self["mesa%d_currentfirmwaredata"% (boardnum)][_STARTOFDATA+pin+(concount*24)]
  3297. temp = self["mesa%dc%dpin%d" % (boardnum,connector,pin) ]
  3298. tempinv = self["mesa%dc%dpin%dinv" % (boardnum,connector,pin) ]
  3299. temptype = self["mesa%dc%dpin%dtype" % (boardnum,connector,pin) ]
  3300. if temptype in(GPIOI,GPIOO,GPIOD):
  3301. compnum = pin+(concount*24)
  3302. if tempinv:
  3303. invmessage = _("invrt")
  3304. else: invmessage =""
  3305. print >>file, ("P%d-%d %d (%d %s) %s %s\n"%(connector,conpin,pin,compnum,temptype,temp,invmessage))
  3306. #print >>file, (" connected to signal:'%(data)s'%(mess)s\n" %{'data':temp, 'mess':invmessage})
  3307. conpin +=2
  3308. print >>file
  3309. templist = ("pp1","pp2","pp3")
  3310. for j, k in enumerate(templist):
  3311. if self.number_pports < (j+1): break
  3312. print >>file, _("%(name)s Parport" % { 'name':k})
  3313. for x in (2,3,4,5,6,7,8,9,10,11,12,13,15):
  3314. temp = self["%sIpin%d" % (k, x)]
  3315. tempinv = self["%sIpin%dinv" % (k, x)]
  3316. if tempinv:
  3317. invmessage = _("-> inverted")
  3318. else: invmessage =""
  3319. print >>file,_("pin# %(pinnum)d is connected to input signal:'%(data)s' %(mesag)s"
  3320. %{ 'pinnum':x,'data':temp,'mesag':invmessage})
  3321. for x in (1,2,3,4,5,6,7,8,9,14,16,17):
  3322. temp = self["%sOpin%d" % (k, x)]
  3323. tempinv = self["%sOpin%dinv" % (k, x)]
  3324. if tempinv:
  3325. invmessage = _("-> inverted")
  3326. else: invmessage =""
  3327. print >>file,_("pin# %(pinnum)d is connected to output signal:'%(data)s' %(mesag)s"
  3328. %{ 'pinnum':x,'data':temp,'mesag':invmessage})
  3329. print >>file
  3330. file.close()
  3331. self.add_md5sum(filename)
  3332. def copy(self, base, filename):
  3333. dest = os.path.join(base, filename)
  3334. if not os.path.exists(dest):
  3335. shutil.copy(os.path.join(distdir, filename), dest)
  3336. def save(self):
  3337. base = os.path.expanduser("~/linuxcnc/configs/%s" % self.machinename)
  3338. ncfiles = os.path.expanduser("~/linuxcnc/nc_files")
  3339. if not os.path.exists(ncfiles):
  3340. makedirs(ncfiles)
  3341. examples = os.path.join(BASE, "share", "linuxcnc", "ncfiles")
  3342. if not os.path.exists(examples):
  3343. examples = os.path.join(BASE, "nc_files")
  3344. if os.path.exists(examples):
  3345. os.symlink(examples, os.path.join(ncfiles, "examples"))
  3346. makedirs(base)
  3347. makedirs(base+"/backups")
  3348. self.md5sums = []
  3349. self.write_readme(base)
  3350. self.write_halfile(base)
  3351. self.write_inifile(base)
  3352. filename = os.path.join(base, "tool.tbl")
  3353. file = open(filename, "w")
  3354. print >>file, "T0 P0 ;"
  3355. print >>file, "T1 P1 ;"
  3356. print >>file, "T2 P2 ;"
  3357. print >>file, "T3 P3 ;"
  3358. file.close()
  3359. filename = "%s.pncconf" % base
  3360. d = xml.dom.minidom.getDOMImplementation().createDocument(
  3361. None, "pncconf", None)
  3362. e = d.documentElement
  3363. for k, v in sorted(self.__dict__.iteritems()):
  3364. if k.startswith("_"): continue
  3365. n = d.createElement('property')
  3366. e.appendChild(n)
  3367. if isinstance(v, float): n.setAttribute('type', 'float')
  3368. elif isinstance(v, bool): n.setAttribute('type', 'bool')
  3369. elif isinstance(v, int): n.setAttribute('type', 'int')
  3370. elif isinstance(v, list): n.setAttribute('type', 'eval')
  3371. else: n.setAttribute('type', 'string')
  3372. n.setAttribute('name', k)
  3373. n.setAttribute('value', str(v))
  3374. d.writexml(open(filename, "wb"), addindent=" ", newl="\n")
  3375. print "%s" % base
  3376. # write pncconf hidden preference file
  3377. filename = os.path.expanduser("~/.pncconf-preferences")
  3378. print filename
  3379. d2 = xml.dom.minidom.getDOMImplementation().createDocument(
  3380. None, "int-pncconf", None)
  3381. e2 = d2.documentElement
  3382. n2 = d2.createElement('property')
  3383. e2.appendChild(n2)
  3384. n2.setAttribute('type', 'float')
  3385. n2.setAttribute('name', "version")
  3386. n2.setAttribute('value', str("%f"%self._preference_version))
  3387. n2 = d2.createElement('property')
  3388. e2.appendChild(n2)
  3389. n2.setAttribute('type', 'bool')
  3390. n2.setAttribute('name', "always_shortcut")
  3391. n2.setAttribute('value', str("%s"% self.createshortcut))
  3392. n2 = d2.createElement('property')
  3393. e2.appendChild(n2)
  3394. n2.setAttribute('type', 'bool')
  3395. n2.setAttribute('name', "always_link")
  3396. n2.setAttribute('value', str("%s"% self.createsymlink))
  3397. n2 = d2.createElement('property')
  3398. e2.appendChild(n2)
  3399. n2.setAttribute('type', 'bool')
  3400. n2.setAttribute('name', "chooselastconfig")
  3401. n2.setAttribute('value', str("%s"% self._chooselastconfig))
  3402. n2 = d2.createElement('property')
  3403. e2.appendChild(n2)
  3404. n2.setAttribute('type', 'string')
  3405. n2.setAttribute('name', "machinename")
  3406. n2.setAttribute('value', str("%s"%self.machinename))
  3407. n2 = d2.createElement('property')
  3408. e2.appendChild(n2)
  3409. n2.setAttribute('type', 'eval')
  3410. n2.setAttribute('name', "mesablacklist")
  3411. n2.setAttribute('value', str(mesablacklist))
  3412. n2 = d2.createElement('property')
  3413. e2.appendChild(n2)
  3414. n2.setAttribute('type', 'string')
  3415. n2.setAttribute('name', "customfirmwarefilename")
  3416. n2.setAttribute('value', str("%s"% self._customfirmwarefilename))
  3417. d2.writexml(open(filename, "wb"), addindent=" ", newl="\n")
  3418. # write to Touchy preference file directly
  3419. if self.frontend == _TOUCHY:
  3420. #print "Setting TOUCHY preferences"
  3421. templist = {"touchyabscolor":"abs_textcolor","touchyrelcolor":"rel_textcolor",
  3422. "touchydtgcolor":"dtg_textcolor","touchyerrcolor":"err_textcolor"}
  3423. for key,value in templist.iteritems():
  3424. prefs.putpref(value, self[key], str)
  3425. if self.touchyposition[0] or self.touchysize[0]:
  3426. pos = size = ""
  3427. if self.touchyposition[0]:
  3428. pos = "+%d+%d"% (self.touchyposition[1],self.touchyposition[2])
  3429. if self.touchysize[0]:
  3430. size = "%dx%d"% (self.touchysize[1],self.touchysize[2])
  3431. geo = "%s%s"%(size,pos)
  3432. else: geo = "default"
  3433. prefs.putpref('window_geometry',geo, str)
  3434. prefs.putpref('gtk_theme',self.touchytheme, str)
  3435. prefs.putpref('window_force_max', self.touchyforcemax, bool)
  3436. # write AXIS rc file for geometry
  3437. if self.frontend == _AXIS and (self.axisposition[0] or self.axissize[0] or self.axisforcemax):
  3438. filename = os.path.expanduser("~/.axisrc")
  3439. if App.warning_dialog(app,"Ok to replace AXIS's .axisrc file?\n\
  3440. If you haven't added custom commands to this hidden file, outside of pncconf, then this should be fine.\n\
  3441. Choosing no will mean AXIS options such as size/position and force maximum might not be as requested \n",False):
  3442. f1 = open(filename, "w")
  3443. if self.axisposition[0] or self.axissize[0]:
  3444. #print "Setting AXIS geometry option"
  3445. pos = size = ""
  3446. if self.axisposition[0]:
  3447. pos = "+%d+%d"% (self.axisposition[1],self.axisposition[2])
  3448. if self.axissize[0]:
  3449. size = "%dx%d"% (self.axissize[1],self.axissize[2])
  3450. geo = "%s%s"%(size,pos)
  3451. print >>f1,"""root_window.tk.call("wm","geometry",".","%s")"""%(geo)
  3452. if self.axisforcemax:
  3453. #print "Setting AXIS forcemax option"
  3454. print >>f1,"""maxgeo=root_window.tk.call("wm","maxsize",".")"""
  3455. print >>f1,"""fullsize=maxgeo.split(' ')[0] + 'x' + maxgeo.split(' ')[1]"""
  3456. print >>f1,"""root_window.tk.call("wm","geometry",".",fullsize)"""
  3457. # make system link and shortcut to pncconf files
  3458. # see http://freedesktop.org/wiki/Software/xdg-user-dirs
  3459. desktop = commands.getoutput("""
  3460. test -f ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs && . ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs
  3461. echo ${XDG_DESKTOP_DIR:-$HOME/Desktop}""")
  3462. if self.createsymlink:
  3463. shortcut = os.path.join(desktop, self.machinename)
  3464. if os.path.exists(desktop) and not os.path.exists(shortcut):
  3465. os.symlink(base,shortcut)
  3466. if self.createshortcut and os.path.exists(desktop):
  3467. if os.path.exists(BASE + "/scripts/linuxcnc"):
  3468. scriptspath = (BASE + "/scripts/linuxcnc")
  3469. else:
  3470. scriptspath ="linuxcnc"
  3471. filename = os.path.join(desktop, "%s.desktop" % self.machinename)
  3472. file = open(filename, "w")
  3473. print >>file,"[Desktop Entry]"
  3474. print >>file,"Version=1.0"
  3475. print >>file,"Terminal=false"
  3476. print >>file,"Name=" + _("launch %s") % self.machinename
  3477. print >>file,"Exec=%s %s/%s.ini" \
  3478. % ( scriptspath, base, self.machinename )
  3479. print >>file,"Type=Application"
  3480. print >>file,"Comment=" + _("Desktop Launcher for LinuxCNC config made by PNCconf")
  3481. print >>file,"Icon=%s"% linuxcncicon
  3482. file.close()
  3483. # Ubuntu 10.04 require launcher to have execute permissions
  3484. os.chmod(filename,0775)
  3485. def __getitem__(self, item):
  3486. return getattr(self, item)
  3487. def __setitem__(self, item, value):
  3488. return setattr(self, item, value)
  3489. # This method returns I/O pin designation (name and number) of a given HAL signalname.
  3490. # It does not check to see if the signalname is in the list more then once.
  3491. # if parports are not used then signals are not searched.
  3492. def findsignal(self, sig):
  3493. if self.number_pports:
  3494. ppinput = {}
  3495. ppoutput = {}
  3496. for i in (1,2,3):
  3497. for s in (2,3,4,5,6,7,8,9,10,11,12,13,15):
  3498. key = self["pp%dIpin%d" %(i,s)]
  3499. ppinput[key] = "pp%dIpin%d" %(i,s)
  3500. for s in (1,2,3,4,5,6,7,8,9,14,16,17):
  3501. key = self["pp%dOpin%d" %(i,s)]
  3502. ppoutput[key] = "pp%dOpin%d" %(i,s)
  3503. mesa = {}
  3504. for boardnum in range(0,int(self.number_mesa)):
  3505. for concount,connector in enumerate(self["mesa%d_currentfirmwaredata"% (boardnum)][_NUMOFCNCTRS]) :
  3506. for s in range(0,24):
  3507. key = self["mesa%dc%dpin%d"% (boardnum,connector,s)]
  3508. mesa[key] = "mesa%dc%dpin%d" %(boardnum,connector,s)
  3509. if self["mesa%d_numof_sserialports"% boardnum]:
  3510. sserial = {}
  3511. port = 0
  3512. for channel in range (0,self["mesa%d_currentfirmwaredata"% boardnum][_MAXSSERIALCHANNELS]):
  3513. if channel >4: break # TODO only have 5 channels worth of glade widgets
  3514. for pin in range (0,_SSCOMBOLEN):
  3515. key = self['mesa%dsserial%d_%dpin%d' % (boardnum, port, channel, pin)]
  3516. sserial[key] = 'mesa%dsserial%d_%dpin%d' % (boardnum, port, channel, pin)
  3517. try:
  3518. return mesa[sig]
  3519. except:
  3520. try:
  3521. return sserial[sig]
  3522. except:
  3523. pass
  3524. if self.number_pports:
  3525. try:
  3526. return ppinput[sig]
  3527. except:
  3528. try:
  3529. return ppoutput[sig]
  3530. except:
  3531. return None
  3532. else: return None
  3533. # search all the current firmware array for related pins
  3534. # if not the same component number as the pin that changed or
  3535. # if not in the relate component type keep searching
  3536. # if is the right component type and number, check the relatedsearch array for a match
  3537. # if its a match add it to a list of pins (pinlist) that need to be updated
  3538. def list_related_pins(self, relatedsearch, boardnum, connector, channel, pin, style):
  3539. #print relatedsearch, boardnum, connector, channel, pin, style
  3540. pinlist =[]
  3541. if not channel == None:
  3542. subfirmname = self["mesa%dsserial%d_%dsubboard"% (boardnum, connector, channel)]
  3543. for subnum,temp in enumerate(mesadaughterdata):
  3544. if mesadaughterdata[subnum][_SUBFIRMNAME] == subfirmname: break
  3545. subboardname = mesadaughterdata[subnum][_SUBBOARDNAME]
  3546. currentptype,currentcompnum = mesadaughterdata[subnum][_SUBSTARTOFDATA+pin]
  3547. for t_pin in range (0,_SSCOMBOLEN):
  3548. comptype,compnum = mesadaughterdata[subnum][_SUBSTARTOFDATA+t_pin]
  3549. if compnum != currentcompnum: continue
  3550. if comptype not in (relatedsearch): continue
  3551. if style == 0:
  3552. tochange = ['mesa%dsserial%d_%dpin%d'% (boardnum,connector,channel,t_pin),boardnum,connector,channel,t_pin]
  3553. if style == 1:
  3554. tochange = ['mesa%dsserial%d_%dpin%dtype'% (boardnum,connector,channel,t_pin),boardnum,connector,channel,t_pin]
  3555. if style == 2:
  3556. tochange = ['mesa%dsserial%d_%dpin%dinv'% (boardnum,connector,channel,t_pin),boardnum,connector,channel,t_pin]
  3557. pinlist.append(tochange)
  3558. else:
  3559. for concount,i in enumerate(self["mesa%d_currentfirmwaredata"% (boardnum)][_NUMOFCNCTRS]):
  3560. if i == connector:
  3561. currentptype,currentcompnum = self["mesa%d_currentfirmwaredata"% (boardnum)][_STARTOFDATA+pin+(concount*24)]
  3562. for t_concount,t_connector in enumerate(self["mesa%d_currentfirmwaredata"% (boardnum)][_NUMOFCNCTRS]):
  3563. for t_pin in range (0,24):
  3564. comptype,compnum = self["mesa%d_currentfirmwaredata"% (boardnum)][_STARTOFDATA+t_pin+(t_concount*24)]
  3565. if compnum != currentcompnum: continue
  3566. if comptype not in (relatedsearch): continue
  3567. if style == 0:
  3568. tochange = ['mesa%dc%dpin%d'% (boardnum,t_connector,t_pin),boardnum,t_connector,None,t_pin]
  3569. if style == 1:
  3570. tochange = ['mesa%dc%dpin%dtype'% (boardnum,t_connector,t_pin),boardnum,t_connector,None,t_pin]
  3571. if style == 2:
  3572. tochange = ['mesa%dc%dpin%dinv'% (boardnum,t_connector,t_pin),boardnum,t_connector,None,t_pin]
  3573. pinlist.append(tochange)
  3574. return pinlist
  3575. # This method takes a signalname data pin (eg mesa0c3pin1)
  3576. # and converts it to a HAL pin names (eg hm2_5i20.0.gpio.01)
  3577. # component number conversion is for adjustment of position of pins related to the
  3578. # 'controlling pin' eg encoder-a (controlling pin) encoder-b encoder -I
  3579. # (a,b,i are related pins for encoder component)
  3580. # gpionumber is a flag to return a gpio piname instead of the component pinname
  3581. # this is used when we want to invert the pins of a component output (such as a stepper)
  3582. # because you actually must invert the GPIO that would be in that position
  3583. # prefixonly flag is used when we want the pin name without the component name.
  3584. # used with sserial when we want the sserial port and channel so we can add out own name (eg enable pins)
  3585. def make_pinname(self, pin, gpionumber = False, prefixonly = False):
  3586. test = str(pin)
  3587. halboardnum = 0
  3588. if test == "None": return None
  3589. elif 'mesa' in test:
  3590. type_name = { GPIOI:"gpio", GPIOO:"gpio", GPIOD:"gpio", ENCA:"encoder", ENCB:"encoder",ENCI:"encoder",ENCM:"encoder",
  3591. RES0:"resolver",RES1:"resolver",RES2:"resolver",RES3:"resolver",RES4:"resolver",RES5:"resolver",
  3592. MXE0:"encoder", MXE1:"encoder",
  3593. PWMP:"pwmgen",PWMD:"pwmgen", PWME:"pwmgen", PDMP:"pwmgen", PDMD:"pwmgen", PDME:"pwmgen",
  3594. UDMU:"pwmgen",UDMD:"pwmgen", UDME:"pwmgen",STEPA:"stepgen", STEPB:"stepgen",
  3595. TPPWMA:"tppwmgen",TPPWMB:"tppwmgen",TPPWMC:"tppwmgen",TPPWMAN:"tppwmgen",TPPWMBN:"tppwmgen",TPPWMCN:"tppwmgen",
  3596. TPPWME:"tppwmgen",TPPWMF:"tppwmgen",AMP8I20:"8i20",POTO:"spinout",POTE:"spinena",POTD:"spindir",ANALOGIN:"analog","Error":"None" }
  3597. boardnum = int(test[4:5])
  3598. boardname = self["mesa%d_currentfirmwaredata"% boardnum][_BOARDNAME]
  3599. ptype = self[pin+"type"]
  3600. if boardnum == 1 and self.mesa1_currentfirmwaredata[_BOARDNAME] == self.mesa0_currentfirmwaredata[_BOARDNAME]:
  3601. halboardnum = 1
  3602. if 'serial' in test:
  3603. # sample pin name = mesa0sserial0_0pin24
  3604. pinnum = int(test[18:])
  3605. portnum = int(test[12:13])
  3606. channel = int(test[14:15])
  3607. subfirmname = self["mesa%dsserial%d_%dsubboard"% (boardnum, portnum, channel)]
  3608. for subnum,temp in enumerate(mesadaughterdata):
  3609. #print "pinname search -",mesadaughterdata[subnum][_SUBFIRMNAME],subfirmname
  3610. if mesadaughterdata[subnum][_SUBFIRMNAME] == subfirmname: break
  3611. #print "pinname -found subboard name:",mesadaughterdata[subnum][_SUBFIRMNAME],subfirmname,subnum,"channel:",channel
  3612. subboardname = mesadaughterdata[subnum][_SUBBOARDNAME]
  3613. firmptype,compnum = mesadaughterdata[subnum][_SUBSTARTOFDATA+pinnum]
  3614. # we iter over this dic because of locale translation problems when using
  3615. # comptype = type_name[ptype]
  3616. comptype = "ERROR FINDING COMPONENT TYPE"
  3617. for key,value in type_name.iteritems():
  3618. if key == ptype: comptype = value
  3619. if value == "Error":
  3620. print "**** ERROR PNCCONF: pintype error in make_pinname: (sserial) ptype = ",ptype
  3621. return None
  3622. # if gpionumber flag is true - convert to gpio pin name
  3623. if gpionumber or ptype in(GPIOI,GPIOO,GPIOD):
  3624. if "7i64" in(subboardname):
  3625. if ptype in(GPIOO,GPIOD):
  3626. comptype = "digout"
  3627. pinnum = pinnum-24 # adjustment for 7i64 pin numbering of output pins vrs pnccnonf numbering
  3628. if ptype == GPIOI:
  3629. comptype = "digin"
  3630. return "hm2_%s.%d.%s.%d.%d."% (boardname,halboardnum,subboardname,portnum,channel) + comptype+".%02d"% (pinnum)
  3631. elif "7i77" in (subboardname) or "7i76" in(subboardname):
  3632. if ptype in(GPIOO,GPIOD):
  3633. comptype = "output"
  3634. if pinnum >15 and pinnum <24:
  3635. pinnum = pinnum-16
  3636. elif pinnum >39:
  3637. pinnum = pinnum -32
  3638. elif ptype == GPIOI:
  3639. comptype = "input"
  3640. if pinnum >23 and pinnum < 40:
  3641. pinnum = pinnum-8
  3642. return "hm2_%s.%d.%s.%d.%d."% (boardname,halboardnum,subboardname,portnum,channel) + comptype+"-%02d"% (pinnum)
  3643. elif "7i69" in (subboardname) or "7i73" in (subboardname):
  3644. if ptype in(GPIOO,GPIOD):
  3645. comptype = "output"
  3646. pinnum -= 24
  3647. elif ptype == GPIOI:
  3648. comptype = "input"
  3649. return "hm2_%s.%d.%s.%d.%d."% (boardname,halboardnum,subboardname,portnum,channel) + comptype+"-%02d"% (pinnum)
  3650. elif "7i70" in (subboardname) or "7i71" in (subboardname):
  3651. if ptype in(GPIOO,GPIOD):
  3652. comptype = "output"
  3653. elif ptype == GPIOI:
  3654. comptype = "input"
  3655. return "hm2_%s.%d.%s.%d.%d."% (boardname,halboardnum,subboardname,portnum,channel) + comptype+"-%02d"% (pinnum)
  3656. else:
  3657. print "**** ERROR PNCCONF: subboard name ",subboardname," in make_pinname: (sserial) ptype = ",ptype,pin
  3658. return None
  3659. elif ptype in (AMP8I20,POTO,POTE,POTD) or prefixonly:
  3660. return "hm2_%s.%d.%s.%d.%d."% (boardname,halboardnum,subboardname,portnum,channel)
  3661. elif ptype in(PWMP,PDMP,UDMU):
  3662. comptype = "analogout"
  3663. return "hm2_%s.%d.%s.%d.%d."% (boardname,halboardnum,subboardname,portnum,channel) + comptype+"%d"% (compnum)
  3664. elif ptype == (ANALOGIN):
  3665. if "7i64" in(subboardname):
  3666. comptype = "adcin"
  3667. return "hm2_%s.%d.%s.%d.%d."% (boardname,halboardnum,subboardname,portnum,channel) + comptype+".%02d"% (compnum)+".in"
  3668. else:
  3669. comptype = "analogin"
  3670. return "hm2_%s.%d.%s.%d.%d."% (boardname,halboardnum,subboardname,portnum,channel) + comptype+"%d"% (compnum)
  3671. elif ptype == (ENCA):
  3672. comptype = "enc"
  3673. return "hm2_%s.%d.%s.%d.%d."% (boardname,halboardnum,subboardname,portnum,channel) + comptype+"%d"% (compnum)
  3674. else:
  3675. print "**** ERROR PNCCONF: pintype error in make_pinname: (sserial) ptype = ",ptype,pin
  3676. return None
  3677. else:
  3678. # sample pin name = mesa0c3pin1
  3679. pinnum = int(test[10:])
  3680. connum = int(test[6:7])
  3681. # we iter over this dic because of locale translation problems when using
  3682. # comptype = type_name[ptype]
  3683. comptype = "ERROR FINDING COMPONENT TYPE"
  3684. # we need concount (connector designations are not in numerical order, pin names are) and comnum from this
  3685. for concount,i in enumerate(self["mesa%d_currentfirmwaredata"% (boardnum)][_NUMOFCNCTRS]):
  3686. if i == connum:
  3687. dummy,compnum = self["mesa%d_currentfirmwaredata"% (boardnum)][_STARTOFDATA+pinnum+(concount*24)]
  3688. break
  3689. for key,value in type_name.iteritems():
  3690. if key == ptype: comptype = value
  3691. if value == "Error":
  3692. print "**** ERROR PNCCONF: pintype error in make_pinname: (mesa) ptype = ",ptype
  3693. return None
  3694. # if gpionumber flag is true - convert to gpio pin name
  3695. if gpionumber or ptype in(GPIOI,GPIOO,GPIOD):
  3696. comptype = "gpio"
  3697. if '5i25' in boardname:
  3698. compnum = int(pinnum)+(concount*16)
  3699. else:
  3700. compnum = int(pinnum)+(concount*24)
  3701. return "hm2_%s.%d."% (boardname,halboardnum) + comptype+".%03d"% (compnum)
  3702. elif ptype in (ENCA,ENCB,ENCI,ENCM,PWMP,PWMD,PWME,PDMP,PDMD,PDME,UDMU,UDMD,UDME,
  3703. STEPA,STEPB,STEPC,STEPD,STEPE,STEPF,TPPWMA,TPPWMB,TPPWMC,TPPWMAN,TPPWMBN,TPPWMCN,TPPWME,TPPWMF):
  3704. return "hm2_%s.%d."% (boardname,halboardnum) + comptype+".%02d"% (compnum)
  3705. elif ptype in (RES0,RES1,RES2,RES3,RES4,RES5):
  3706. temp = (RES0,RES1,RES2,RES3,RES4,RES5)
  3707. for num,dummy in enumerate(temp):
  3708. if ptype == dummy:break
  3709. return "hm2_%s.%d."% (boardname,halboardnum) + comptype+".%02d"% (compnum*6+num)
  3710. elif ptype in (MXE0,MXE1):
  3711. num = 0
  3712. if ptype == MXE1: num = 1
  3713. return "hm2_%s.%d."% (boardname,halboardnum) + comptype+".%02d"% ((compnum * 2 + num))
  3714. elif 'pp' in test:
  3715. #print test
  3716. ending = "-out"
  3717. test = str(pin)
  3718. #print self[pin]
  3719. pintype = str(test[3:4])
  3720. pinnum = int(test[7:])
  3721. connum = int(test[2:3])-1
  3722. if pintype == 'I': ending = "-in"
  3723. return "parport."+str(connum)+".pin-%02d"%(pinnum)+ending
  3724. else:
  3725. print "pintype error in make_pinname: pinname = ",test
  3726. return None
  3727. class App:
  3728. fname = 'pncconf.glade' # XXX search path
  3729. def _getwidget(self, doc, id):
  3730. for i in doc.getElementsByTagName('widget'):
  3731. if i.getAttribute('id') == id: return i
  3732. def make_axispage(self, doc, axisname):
  3733. axispage = self._getwidget(doc, 'xaxis').parentNode.cloneNode(True)
  3734. nextpage = self._getwidget(doc, 'advanced').parentNode
  3735. widget = self._getwidget(axispage, "xaxis")
  3736. for node in widget.childNodes:
  3737. if (node.nodeType == xml.dom.Node.ELEMENT_NODE
  3738. and node.tagName == "property"
  3739. and node.getAttribute('name') == "title"):
  3740. node.childNodes[0].data = _("%s Axis Configuration") % axisname.upper()
  3741. for node in axispage.getElementsByTagName("widget"):
  3742. id = node.getAttribute('id')
  3743. if id.startswith("x"):
  3744. node.setAttribute('id', axisname + id[1:])
  3745. else:
  3746. node.setAttribute('id', axisname + id)
  3747. for node in axispage.getElementsByTagName("signal"):
  3748. handler = node.getAttribute('handler')
  3749. node.setAttribute('handler', handler.replace("on_x", "on_" + axisname))
  3750. for node in axispage.getElementsByTagName("property"):
  3751. name = node.getAttribute('name')
  3752. if name == "mnemonic_widget":
  3753. node.childNodes[0].data = axisname + node.childNodes[0].data[1:]
  3754. nextpage.parentNode.insertBefore(axispage, nextpage)
  3755. def make_axismotorpage(self, doc, axisname):
  3756. axispage = self._getwidget(doc, 'xaxismotor').parentNode.cloneNode(True)
  3757. nextpage = self._getwidget(doc, 'xaxis').parentNode
  3758. widget = self._getwidget(axispage, "xaxismotor")
  3759. for node in widget.childNodes:
  3760. if (node.nodeType == xml.dom.Node.ELEMENT_NODE
  3761. and node.tagName == "property"
  3762. and node.getAttribute('name') == "title"):
  3763. if axisname =="s":
  3764. node.childNodes[0].data = _("Spindle Motor/Encoder Configuration")
  3765. else:
  3766. node.childNodes[0].data = _("%s Axis Motor/Encoder Configuration") % axisname.upper()
  3767. for node in axispage.getElementsByTagName("widget"):
  3768. id = node.getAttribute('id')
  3769. if id.startswith("x"):
  3770. node.setAttribute('id', axisname + id[1:])
  3771. else:
  3772. node.setAttribute('id', axisname + id)
  3773. for node in axispage.getElementsByTagName("signal"):
  3774. handler = node.getAttribute('handler')
  3775. node.setAttribute('handler', handler.replace("on_x", "on_" + axisname))
  3776. for node in axispage.getElementsByTagName("property"):
  3777. name = node.getAttribute('name')
  3778. if name == "mnemonic_widget":
  3779. node.childNodes[0].data = axisname + node.childNodes[0].data[1:]
  3780. if name == "group":
  3781. group = node.childNodes[0].data
  3782. if group.startswith("x"):
  3783. node.childNodes[0].data = axisname + node.childNodes[0].data[1:]
  3784. nextpage.parentNode.insertBefore(axispage, nextpage)
  3785. def make_pportpage(self, doc, axisname):
  3786. axispage = self._getwidget(doc, 'pp1pport').parentNode.cloneNode(True)
  3787. nextpage = self._getwidget(doc, 'xaxismotor').parentNode
  3788. widget = self._getwidget(axispage, "pp1pport")
  3789. for node in widget.childNodes:
  3790. if (node.nodeType == xml.dom.Node.ELEMENT_NODE
  3791. and node.tagName == "property"
  3792. and node.getAttribute('name') == "title"):
  3793. node.childNodes[0].data = _("%s Parallel Port Setup") % axisname
  3794. for node in axispage.getElementsByTagName("widget"):
  3795. id = node.getAttribute('id')
  3796. if id.startswith("pp1"):
  3797. node.setAttribute('id', axisname + id[3:])
  3798. else:
  3799. node.setAttribute('id', axisname + id)
  3800. for node in axispage.getElementsByTagName("signal"):
  3801. handler = node.getAttribute('handler')
  3802. node.setAttribute('handler', handler.replace("on_pp1", "on_" + axisname))
  3803. for node in axispage.getElementsByTagName("property"):
  3804. name = node.getAttribute('name')
  3805. if name == "mnemonic_widget":
  3806. node.childNodes[0].data = axisname + node.childNodes[0].data[1:]
  3807. nextpage.parentNode.insertBefore(axispage, nextpage)
  3808. def make_mesapage(self, doc, axisname):
  3809. axispage = self._getwidget(doc, 'mesa0').parentNode.cloneNode(True)
  3810. nextpage = self._getwidget(doc, 'pp1pport').parentNode
  3811. widget = self._getwidget(axispage, "mesa0")
  3812. for node in widget.childNodes:
  3813. if (node.nodeType == xml.dom.Node.ELEMENT_NODE
  3814. and node.tagName == "property"
  3815. and node.getAttribute('name') == "title"):
  3816. node.childNodes[0].data = _("%s I/0 Setup") % axisname
  3817. for node in axispage.getElementsByTagName("widget"):
  3818. id = node.getAttribute('id')
  3819. if id.startswith("mesa0"):
  3820. node.setAttribute('id', axisname + id[5:])
  3821. else:
  3822. node.setAttribute('id', axisname + id)
  3823. for node in axispage.getElementsByTagName("signal"):
  3824. handler = node.getAttribute('handler')
  3825. node.setAttribute('handler', handler.replace("on_mesa0", "on_" + axisname))
  3826. for node in axispage.getElementsByTagName("property"):
  3827. name = node.getAttribute('name')
  3828. if name == "mnemonic_widget":
  3829. node.childNodes[0].data = axisname + node.childNodes[0].data[1:]
  3830. nextpage.parentNode.insertBefore(axispage, nextpage)
  3831. def splash_screen(self):
  3832. self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
  3833. self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_SPLASHSCREEN)
  3834. self.window.set_title("Pncconf setup")
  3835. self.window.set_border_width(10)
  3836. vbox = gtk.VBox(False, 5)
  3837. vbox.set_border_width(10)
  3838. self.window.add(vbox)
  3839. vbox.show()
  3840. align = gtk.Alignment(0.5, 0.5, 0, 0)
  3841. vbox.pack_start(align, False, False, 5)
  3842. align.show()
  3843. self.pbar = gtk.ProgressBar()
  3844. self.pbar.set_text("Pncconf is setting up")
  3845. self.pbar.set_fraction(.1)
  3846. align.add(self.pbar)
  3847. self.pbar.show()
  3848. self.window.show()
  3849. while gtk.events_pending():
  3850. gtk.main_iteration()
  3851. def __init__(self, debug=0):
  3852. print 'debug=',debug
  3853. if debug:
  3854. global _DEBUGSTRING
  3855. _DEBUGSTRING = ['all']
  3856. gnome.init("pncconf", "0.6")
  3857. self.splash_screen()
  3858. glade = xml.dom.minidom.parse(os.path.join(datadir, self.fname))
  3859. self.make_axispage(glade, 'y')
  3860. self.make_axispage(glade, 'z')
  3861. self.make_axispage(glade, 'a')
  3862. self.pbar.set_fraction(.2)
  3863. while gtk.events_pending():
  3864. gtk.main_iteration()
  3865. self.make_axismotorpage(glade, 'y')
  3866. self.make_axismotorpage(glade, 'z')
  3867. self.make_axismotorpage(glade, 'a')
  3868. self.make_axismotorpage(glade, 's')
  3869. self.pbar.set_fraction(.3)
  3870. while gtk.events_pending():
  3871. gtk.main_iteration()
  3872. self.make_pportpage(glade, 'pp2')
  3873. self.make_pportpage(glade, 'pp3')
  3874. self.make_mesapage(glade, 'mesa1')
  3875. self.pbar.set_fraction(.4)
  3876. while gtk.events_pending():
  3877. gtk.main_iteration()
  3878. doc = glade.toxml().encode("utf-8")
  3879. self.pbar.set_fraction(.75)
  3880. while gtk.events_pending():
  3881. gtk.main_iteration()
  3882. self.xml = gtk.glade.xml_new_from_buffer(doc, len(doc), domain="linuxcnc")
  3883. self.window.hide()
  3884. self.widgets = Widgets(self.xml)
  3885. self.watermark = gtk.gdk.pixbuf_new_from_file(wizard)
  3886. axisdiagram = os.path.join(helpdir,"axisdiagram1.png")
  3887. self.widgets.helppic0.set_from_file(axisdiagram)
  3888. axisdiagram = os.path.join(helpdir,"lathe_diagram.png")
  3889. self.widgets.helppic1.set_from_file(axisdiagram)
  3890. self.widgets.openloopdialog.hide()
  3891. self.widgets.druidpagestart1.set_watermark(self.watermark)
  3892. self.widgets.complete.set_watermark(self.watermark)
  3893. self.widgets.druidpagestart1.show()
  3894. self.widgets.complete.show()
  3895. self.xml.signal_autoconnect(self)
  3896. self.in_pport_prepare = False
  3897. self.axis_under_test = False
  3898. self.jogminus = self.jogplus = 0
  3899. self.data = Data()
  3900. # add some custom signals for motor/encoder scaling and bldc
  3901. for axis in ["x","y","z","a","s"]:
  3902. cb = ["encoderscale","stepscale"]
  3903. for i in cb:
  3904. self.widgets[axis + i].connect("value-changed", self.motor_encoder_sanity_check,axis)
  3905. cb = ["bldc_incremental_feedback","bldc_use_hall","bldc_use_encoder","bldc_use_index","bldc_fanuc_alignment","bldc_emulated_feedback",
  3906. "bldc_output_hall"]
  3907. for i in cb:
  3908. self.widgets[axis + i].connect("clicked", self.bldc_update,axis)
  3909. # connect signals with pin designation data to mesa signal comboboxes and pintype comboboxes
  3910. # record the signal ID numbers so we can block the signals later in the mesa routines
  3911. # have to do it here manually (instead of autoconnect) because glade doesn't handle added
  3912. # user info (board/connector/pin number designations) and doesn't record the signal ID numbers
  3913. # none of this is done if mesa is not checked off in pncconf
  3914. # TODO we should check to see if signals are already present as each time user goes though this page
  3915. # the signals get added again causing multple calls to the functions.
  3916. if (self.data.number_mesa):
  3917. for boardnum in (0,1):
  3918. cb = "mesa%d_comp_update"% (boardnum)
  3919. i = "_mesa%dsignalhandler_comp_update"% (boardnum)
  3920. self.data[i] = int(self.widgets[cb].connect("clicked", self.on_mesa_component_value_changed,boardnum))
  3921. cb = "mesa%d_boardtitle"% (boardnum)
  3922. i = "_mesa%dsignalhandler_boardname_change"% (boardnum)
  3923. self.data[i] = int(self.widgets[cb].connect("changed", self.on_mesa_boardname_changed,boardnum))
  3924. cb = "mesa%d_firmware"% (boardnum)
  3925. i = "_mesa%dsignalhandler_firmware_change"% (boardnum)
  3926. self.data[i] = int(self.widgets[cb].connect("changed", self.on_mesa_firmware_changed,boardnum))
  3927. for connector in (2,3,4,5,6,7,8,9):
  3928. for pin in range(0,24):
  3929. cb = "mesa%dc%ipin%i"% (boardnum,connector,pin)
  3930. i = "_mesa%dsignalhandlerc%ipin%i"% (boardnum,connector,pin)
  3931. self.data[i] = int(self.widgets[cb].connect("changed",
  3932. self.on_general_pin_changed,"mesa",boardnum,connector,None,pin,False))
  3933. i = "_mesa%dactivatehandlerc%ipin%i"% (boardnum,connector,pin)
  3934. self.data[i] = int(self.widgets[cb].child.connect("activate",
  3935. self.on_general_pin_changed,"mesa",boardnum,connector,None,pin,True))
  3936. cb = "mesa%dc%ipin%itype"% (boardnum,connector,pin)
  3937. i = "_mesa%dptypesignalhandlerc%ipin%i"% (boardnum,connector,pin)
  3938. self.data[i] = int(self.widgets[cb].connect("changed", self.on_mesa_pintype_changed,boardnum,connector,None,pin))
  3939. port = 0 #TODO we only support one serial port
  3940. for channel in range (0,5):# TODO only have 5 channels worth of glade widgets
  3941. for pin in range (0,_SSCOMBOLEN):
  3942. cb = "mesa%dsserial%i_%ipin%i"% (boardnum,port,channel,pin)
  3943. i = "_mesa%dsignalhandlersserial%i_%ipin%i"% (boardnum,port,channel,pin)
  3944. self.data[i] = int(self.widgets[cb].connect("changed",
  3945. self.on_general_pin_changed,"sserial",boardnum,port,channel,pin,False))
  3946. i = "_mesa%dactivatehandlersserial%i_%ipin%i"% (boardnum,port,channel,pin)
  3947. self.data[i] = int(self.widgets[cb].child.connect("activate",
  3948. self.on_general_pin_changed,"sserial",boardnum,port,channel,pin,True))
  3949. cb = "mesa%dsserial%i_%ipin%itype"% (boardnum,port,channel,pin)
  3950. i = "_mesa%dptypesignalhandlersserial%i_%ipin%i"% (boardnum,port,channel,pin)
  3951. self.data[i] = int(self.widgets[cb].connect("changed", self.on_mesa_pintype_changed,boardnum,port,channel,pin))
  3952. for connector in("pp1","pp2","pp3"):
  3953. # initialize parport input / inv pins
  3954. for pin in (2,3,4,5,6,7,8,9,10,11,12,13,15):
  3955. cb = "%sIpin%d"% (connector,pin)
  3956. i = "_%ssignalhandler"% cb
  3957. self.data[i] = int(self.widgets[cb].connect("changed", self.on_general_pin_changed,"parport",connector,"Ipin",None,pin,False))
  3958. i = "_%sactivatehandler"% cb
  3959. self.data[i] = int(self.widgets[cb].child.connect("activate", self.on_general_pin_changed,"parport",connector,"Ipin",None,pin,True))
  3960. # initialize parport output / inv pins
  3961. for pin in (1,2,3,4,5,6,7,8,9,14,16,17):
  3962. cb = "%sOpin%d"% (connector,pin)
  3963. i = "_%ssignalhandler"% cb
  3964. self.data[i] = int(self.widgets[cb].connect("changed", self.on_general_pin_changed,"parport",connector,"Opin",None,pin,False))
  3965. i = "_%sactivatehandler"% cb
  3966. self.data[i] = int(self.widgets[cb].child.connect("activate", self.on_general_pin_changed,"parport",connector,"Opin",None,pin,True))
  3967. # set preferences if they exist
  3968. link = short = False
  3969. filename = os.path.expanduser("~/.pncconf-preferences")
  3970. if os.path.exists(filename):
  3971. match = open(filename).read()
  3972. textbuffer = self.widgets.textoutput.get_buffer()
  3973. try :
  3974. textbuffer.set_text("%s\n\n"% filename)
  3975. textbuffer.insert_at_cursor(match)
  3976. except:
  3977. pass
  3978. version = 0.0
  3979. d = xml.dom.minidom.parse(open(filename, "r"))
  3980. for n in d.getElementsByTagName("property"):
  3981. name = n.getAttribute("name")
  3982. text = n.getAttribute('value')
  3983. if name == "version":
  3984. version = eval(text)
  3985. if name == "always_shortcut":
  3986. short = eval(text)
  3987. if name == "always_link":
  3988. link = eval(text)
  3989. if name == "machinename":
  3990. self.data._lastconfigname = text
  3991. if name == "chooselastconfig":
  3992. self.data._chooselastconfig = eval(text)
  3993. if name == "mesablacklist":
  3994. if version == self.data._preference_version:
  3995. global mesablacklist
  3996. mesablacklist = eval(text)
  3997. if name == "customfirmwarefilename":
  3998. global custommesafirmwaredata
  3999. self.data._customfirmwarefilename = text
  4000. rcfile = os.path.expanduser(self.data._customfirmwarefilename)
  4001. print rcfile
  4002. if os.path.exists(rcfile):
  4003. try:
  4004. execfile(rcfile)
  4005. except:
  4006. print "**** PNCCONF ERROR: custom firmware loading error"
  4007. custommesafirmwaredata = []
  4008. if not custommesafirmwaredata == []:
  4009. print "**** PNCCONF INFO: Found extra firmware in file"
  4010. self.widgets.createsymlink.set_active(link)
  4011. self.widgets.createshortcut.set_active(short)
  4012. tempfile = os.path.join(distdir, "configurable_options/ladder/TEMP.clp")
  4013. if os.path.exists(tempfile):
  4014. os.remove(tempfile)
  4015. def gtk_main_quit(self, *args):
  4016. gtk.main_quit()
  4017. def on_window1_delete_event(self, *args):
  4018. if self.warning_dialog (_("Quit PNCconfig and discard changes?"),False):
  4019. gtk.main_quit()
  4020. return False
  4021. else:
  4022. return True
  4023. on_druid1_cancel = on_window1_delete_event
  4024. def warning_dialog(self,message,is_ok_type):
  4025. if is_ok_type:
  4026. dialog = gtk.MessageDialog(app.widgets.window1,
  4027. gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
  4028. gtk.MESSAGE_WARNING, gtk.BUTTONS_OK,message)
  4029. dialog.show_all()
  4030. result = dialog.run()
  4031. dialog.destroy()
  4032. return True
  4033. else:
  4034. dialog = gtk.MessageDialog(self.widgets.window1,
  4035. gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
  4036. gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO,message)
  4037. dialog.show_all()
  4038. result = dialog.run()
  4039. dialog.destroy()
  4040. if result == gtk.RESPONSE_YES:
  4041. return True
  4042. else:
  4043. return False
  4044. def on_helpwindow_delete_event(self, *args):
  4045. self.widgets.helpwindow.hide()
  4046. return True
  4047. def on_druid1_help(self, *args):
  4048. helpfilename = os.path.join(helpdir, "%s"% self.data.help)
  4049. textbuffer = self.widgets.helpview.get_buffer()
  4050. try :
  4051. infile = open(helpfilename, "r")
  4052. if infile:
  4053. string = infile.read()
  4054. infile.close()
  4055. textbuffer.set_text(string)
  4056. self.widgets.helpwindow.set_title(_("Help Pages") )
  4057. self.widgets.helpnotebook.set_current_page(0)
  4058. self.widgets.helpwindow.show_all()
  4059. self.widgets.helpwindow.present()
  4060. except:
  4061. text = _("Help page is unavailable\n")
  4062. self.warning_dialog(text,True)
  4063. def check_for_rt(self,fussy=True):
  4064. actual_kernel = os.uname()[2]
  4065. if hal.is_sim == 1 :
  4066. if fussy:
  4067. self.warning_dialog(_("You are using a simulated-realtime version of LinuxCNC, so testing / tuning of external hardware is unavailable."),True)
  4068. return False
  4069. else:
  4070. return True
  4071. elif hal.is_rt and not hal.kernel_version == actual_kernel:
  4072. self.warning_dialog(_("""You are using a realtime version of LinuxCNC but didn't load a realtime kernel so testing / tuning of external hardware is unavailable.\n This is probably because you updated the OS and it doesn't load the RTAI kernel anymore\n You are using the %(actual)s kernel instead of %(needed)s""")% {'actual':actual_kernel, 'needed':hal.kernel_version},True)
  4073. return False
  4074. else:
  4075. return True
  4076. def on_page_newormodify_prepare(self, *args):
  4077. global mesaboardnames
  4078. global mesafirmwaredata
  4079. self.data.help = "help-load.txt"
  4080. # search for firmware packages
  4081. if os.path.exists(firmdir):
  4082. mesaboardnames = []
  4083. for root, dirs, files in os.walk(firmdir):
  4084. folder = root.lstrip(firmdir)
  4085. if folder in mesablacklist:continue
  4086. if folder == "":continue
  4087. mesaboardnames.append(folder)
  4088. #print "\n**** ",folder,":\n"
  4089. else:
  4090. #TODO what if there are no external firmware is this enough?
  4091. self.warning_dialog(_("You are have no hostmot2 firmware downloaded in folder:\n%s\n\
  4092. PNCconf will use sample firmware data\nlive testing will not be possible"%firmdir),True)
  4093. # add any extra firmware boardnames from .pncconf-preference file
  4094. if not custommesafirmwaredata == []:
  4095. for search, item in enumerate(custommesafirmwaredata):
  4096. d = custommesafirmwaredata[search]
  4097. if not d[_BOARDTITLE] in mesaboardnames:
  4098. mesaboardnames.append(d[_BOARDTITLE])
  4099. def on_page_newormodify_next(self, *args):
  4100. if not self.widgets.createconfig.get_active():
  4101. filter = gtk.FileFilter()
  4102. filter.add_pattern("*.pncconf")
  4103. filter.set_name(_("LinuxCNC 'PNCconf' configuration files"))
  4104. dialog = gtk.FileChooserDialog(_("Modify Existing Configuration"),
  4105. self.widgets.window1, gtk.FILE_CHOOSER_ACTION_OPEN,
  4106. (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
  4107. gtk.STOCK_OPEN, gtk.RESPONSE_OK))
  4108. dialog.set_default_response(gtk.RESPONSE_OK)
  4109. dialog.add_filter(filter)
  4110. if not self.data._lastconfigname == "" and self.data._chooselastconfig:
  4111. dialog.set_filename(os.path.expanduser("~/linuxcnc/configs/%s.pncconf"% self.data._lastconfigname))
  4112. dialog.add_shortcut_folder(os.path.expanduser("~/linuxcnc/configs"))
  4113. dialog.set_current_folder(os.path.expanduser("~/linuxcnc/configs"))
  4114. dialog.show_all()
  4115. result = dialog.run()
  4116. if result == gtk.RESPONSE_OK:
  4117. filename = dialog.get_filename()
  4118. dialog.destroy()
  4119. self.data.load(filename, self)
  4120. self.data._mesa0_configured = False
  4121. self.data._mesa1_configured = False
  4122. try:
  4123. # check that the firmware is current enough by checking the length of a sub element and that the other is an integer.
  4124. for boardnum in(0,1):
  4125. i=j=None
  4126. i = len(self.data["mesa%d_currentfirmwaredata"% boardnum][_NUMOFCNCTRS])
  4127. j = self.data["mesa%d_currentfirmwaredata"% boardnum][_HIFREQ]+100 # throws an error if not an integer.
  4128. if not i > 1:
  4129. print i,j,boardnum
  4130. raise UserWarning
  4131. except :
  4132. print i,j,boardnum
  4133. self.warning_dialog(_("It seems data in this file is from too old of a version of PNCConf to continue.\n."),True)
  4134. return True
  4135. else:
  4136. dialog.destroy()
  4137. return True
  4138. self.data.createsymlink = self.widgets.createsymlink.get_active()
  4139. self.data.createshortcut = self.widgets.createshortcut.get_active()
  4140. self.widgets.window1.set_title(_("Point and click configuration - %s.pncconf ") % self.data.machinename)
  4141. # here we initalise the mesa configure page data
  4142. #TODO is this right place?
  4143. self.data._mesa0_configured = False
  4144. self.data._mesa1_configured = False
  4145. self.fill_pintype_model()
  4146. self.fill_combobox_models()
  4147. def on_page_newormodify_back(self, *args):
  4148. self.data.help = "help-welcome.txt"
  4149. def on_basicinfo_prepare(self, *args):
  4150. self.data.help = "help-basic.txt"
  4151. self.widgets.machinename.set_text(self.data.machinename)
  4152. self.widgets.axes.set_active(self.data.axes)
  4153. self.widgets.units.set_active(self.data.units)
  4154. self.widgets.servoperiod.set_value(self.data.servoperiod)
  4155. self.widgets.machinename.grab_focus()
  4156. if self.data.number_mesa == 1:
  4157. self.widgets.mesa0_checkbutton.set_active(True)
  4158. self.widgets.mesa1_checkbutton.set_active(False)
  4159. elif self.data.number_mesa == 2:
  4160. self.widgets.mesa0_checkbutton.set_active(True)
  4161. self.widgets.mesa1_checkbutton.set_active(True)
  4162. else:
  4163. self.widgets.mesa0_checkbutton.set_active(False)
  4164. self.widgets.mesa1_checkbutton.set_active(False)
  4165. self.widgets.ioaddr.set_text(self.data.ioaddr)
  4166. self.widgets.ioaddr2.set_text(self.data.ioaddr2)
  4167. self.widgets.ioaddr3.set_text(self.data.ioaddr3)
  4168. self.widgets.pp1_direction.set_active(self.data.pp1_direction)
  4169. self.widgets.pp2_direction.set_active(self.data.pp2_direction)
  4170. self.widgets.pp3_direction.set_active(self.data.pp3_direction)
  4171. if self.data.number_pports>0:
  4172. self.widgets.pp1_checkbutton.set_active(1)
  4173. else :
  4174. self.widgets.pp1_checkbutton.set_active(0)
  4175. if self.data.number_pports>1:
  4176. self.widgets.pp2_checkbutton.set_active(1)
  4177. if self.data.number_pports>2:
  4178. self.widgets.pp3_checkbutton.set_active(1)
  4179. if self.data.frontend == _AXIS : self.widgets.GUIAXIS.set_active(True)
  4180. elif self.data.frontend == _TKLINUXCNC: self.widgets.GUITKLINUXCNC.set_active(True)
  4181. elif self.data.frontend == _MINI: self.widgets.GUIMINI.set_active(True)
  4182. elif self.data.frontend == _TOUCHY: self.widgets.GUITOUCHY.set_active(True)
  4183. if not self.data._arrayloaded:
  4184. for boardnum in(0,1):
  4185. temp = 0
  4186. model = self.widgets["mesa%d_boardtitle"% boardnum].get_model()
  4187. model.clear()
  4188. for search,item in enumerate(mesaboardnames):
  4189. model.append((item,))
  4190. if mesaboardnames[search] == self.data["mesa%d_boardtitle"% boardnum]:
  4191. temp = search
  4192. self.widgets["mesa%d_boardtitle"% boardnum].set_active(temp)
  4193. def on_mesa_checkbutton_toggled(self, *args):
  4194. i = self.widgets.mesa0_checkbutton.get_active()
  4195. j = self.widgets.mesa1_checkbutton.get_active()
  4196. self.widgets.mesa0_boardtitle.set_sensitive(i)
  4197. self.widgets.mesa1_boardtitle.set_sensitive(j)
  4198. if j and not i:
  4199. self.widgets.mesa1_checkbutton.set_active(False)
  4200. self.widgets.mesa1_boardtitle.set_sensitive(False)
  4201. def on_pp1_checkbutton_toggled(self, *args):
  4202. i = self.widgets.pp1_checkbutton.get_active()
  4203. self.widgets.pp1_direction.set_sensitive(i)
  4204. self.widgets.ioaddr.set_sensitive(i)
  4205. if i == 0:
  4206. self.widgets.pp2_checkbutton.set_active(i)
  4207. self.widgets.ioaddr2.set_sensitive(i)
  4208. self.widgets.pp3_checkbutton.set_active(i)
  4209. self.widgets.ioaddr3.set_sensitive(i)
  4210. def on_pp2_checkbutton_toggled(self, *args):
  4211. i = self.widgets.pp2_checkbutton.get_active()
  4212. if self.widgets.pp1_checkbutton.get_active() == 0:
  4213. i = 0
  4214. self.widgets.pp2_checkbutton.set_active(0)
  4215. self.widgets.pp2_direction.set_sensitive(i)
  4216. self.widgets.ioaddr2.set_sensitive(i)
  4217. if i == 0:
  4218. self.widgets.pp3_checkbutton.set_active(i)
  4219. self.widgets.ioaddr3.set_sensitive(i)
  4220. def on_pp3_checkbutton_toggled(self, *args):
  4221. i = self.widgets.pp3_checkbutton.get_active()
  4222. if self.widgets.pp2_checkbutton.get_active() == 0:
  4223. i = 0
  4224. self.widgets.pp3_checkbutton.set_active(0)
  4225. self.widgets.pp3_direction.set_sensitive(i)
  4226. self.widgets.ioaddr3.set_sensitive(i)
  4227. def on_basicinfo_next(self, *args):
  4228. machinename= self.widgets.machinename.get_text()
  4229. self.data.machinename = machinename.replace(" ","_")
  4230. self.widgets.window1.set_title(_("Point and click configuration - %s.pncconf ") % self.data.machinename)
  4231. self.data.axes = self.widgets.axes.get_active()
  4232. if self.data.axes == 0: self.data.available_axes = ['x','y','z','s']
  4233. elif self.data.axes == 1: self.data.available_axes = ['x','y','z','a','s']
  4234. elif self.data.axes == 2: self.data.available_axes = ['x','z','s']
  4235. self.data.units = self.widgets.units.get_active()
  4236. self.data.servoperiod = self.widgets.servoperiod.get_value()
  4237. self.data.ioaddr = self.widgets.ioaddr.get_text()
  4238. self.data.ioaddr2 = self.widgets.ioaddr2.get_text()
  4239. self.data.ioaddr3 = self.widgets.ioaddr3.get_text()
  4240. i = self.widgets.mesa0_checkbutton.get_active()
  4241. j = self.widgets.mesa1_checkbutton.get_active()
  4242. self.data.number_mesa = int(i)+int(j)
  4243. if self.widgets.pp3_checkbutton.get_active() and self.widgets.pp2_checkbutton.get_active():
  4244. self.data.number_pports = 3
  4245. elif self.widgets.pp2_checkbutton.get_active() and self.widgets.pp1_checkbutton.get_active():
  4246. self.data.number_pports = 2
  4247. elif self.widgets.pp1_checkbutton.get_active():
  4248. self.data.number_pports = 1
  4249. else :
  4250. self.data.number_pports = 0
  4251. if self.data.number_pports == 0 and self.data.number_mesa== 0 :
  4252. self.warning_dialog(_("You need to designate a parport and/or mesa I/O device before continuing."),True)
  4253. self.widgets.druid1.set_page(self.widgets.basicinfo)
  4254. return True
  4255. self.data.pp1_direction = self.widgets.pp1_direction.get_active()
  4256. self.data.pp2_direction = self.widgets.pp2_direction.get_active()
  4257. self.data.pp3_direction = self.widgets.pp3_direction.get_active()
  4258. if self.widgets.GUIAXIS.get_active():
  4259. self.data.frontend = _AXIS
  4260. elif self.widgets.GUITKLINUXCNC.get_active():
  4261. self.data.frontend = _TKLINUXCNC
  4262. elif self.widgets.GUIMINI.get_active():
  4263. self.data.frontend = _MINI
  4264. elif self.widgets.GUITOUCHY.get_active():
  4265. self.data.frontend = _TOUCHY
  4266. i = self.widgets.mesa0_boardtitle.get_active_text()
  4267. j = self.widgets.mesa1_boardtitle.get_active_text()
  4268. # check for installed firmware
  4269. if not self.data._arrayloaded or not self.data.mesa0_boardtitle == i or not self.data.mesa1_boardtitle == j:
  4270. global mesafirmwaredata
  4271. if os.path.exists(os.path.join(firmdir,i)) or os.path.exists(os.path.join(firmdir,j)):
  4272. mesafirmwaredata = []
  4273. self.mesa_firmware_search(i)
  4274. if self.data.number_mesa == 2 and not i == j: self.mesa_firmware_search(j)
  4275. self.data._arrayloaded = True
  4276. # add any extra firmware data from .pncconf-preference file
  4277. if not custommesafirmwaredata == []:
  4278. for i,j in enumerate(custommesafirmwaredata):
  4279. mesafirmwaredata.append(custommesafirmwaredata[i])
  4280. # ok set up mesa info
  4281. for boardnum in (0,1):
  4282. model = self.widgets["mesa%d_firmware"% boardnum].get_model()
  4283. model.clear()
  4284. temp=[]
  4285. for search, item in enumerate(mesafirmwaredata):
  4286. d = mesafirmwaredata[search]
  4287. if not d[_BOARDTITLE] == self.widgets["mesa%d_boardtitle"% boardnum].get_active_text():continue
  4288. temp.append(d[_FIRMWARE])
  4289. temp.sort()
  4290. for i in temp:
  4291. model.append((i,))
  4292. for search,item in enumerate(model):
  4293. if model[search][0] == self.data["mesa%d_firmware"% boardnum]:
  4294. self.widgets["mesa%d_firmware"% boardnum].set_active(search)
  4295. break
  4296. if search == (len(model)-1):
  4297. self.widgets["mesa%d_firmware"% boardnum].set_active(0)
  4298. self.on_mesa_firmware_changed( None,boardnum)
  4299. else:
  4300. self.widgets["mesa%d_pwm_frequency"% boardnum].set_value(self.data["mesa%d_pwm_frequency"% boardnum])
  4301. self.widgets["mesa%d_pdm_frequency"% boardnum].set_value(self.data["mesa%d_pdm_frequency"% boardnum])
  4302. self.widgets["mesa%d_3pwm_frequency"% boardnum].set_value(self.data["mesa%d_3pwm_frequency"% boardnum])
  4303. self.widgets["mesa%d_watchdog_timeout"% boardnum].set_value(self.data["mesa%d_watchdog_timeout"% boardnum])
  4304. self.widgets["mesa%d_numof_encodergens"% boardnum].set_value(self.data["mesa%d_numof_encodergens"% boardnum])
  4305. self.widgets["mesa%d_numof_pwmgens"% boardnum].set_value(self.data["mesa%d_numof_pwmgens"% boardnum])
  4306. self.widgets["mesa%d_numof_tppwmgens"% boardnum].set_value(self.data["mesa%d_numof_tppwmgens"% boardnum])
  4307. self.widgets["mesa%d_numof_stepgens"% boardnum].set_value(self.data["mesa%d_numof_stepgens"% boardnum])
  4308. self.widgets["mesa%d_numof_sserialports"% boardnum].set_value(self.data["mesa%d_numof_sserialports"% boardnum])
  4309. self.widgets["mesa%d_numof_sserialchannels"% boardnum].set_value(self.data["mesa%d_numof_sserialchannels"% boardnum])
  4310. self.data.mesa0_boardtitle = self.widgets.mesa0_boardtitle.get_active_text()
  4311. self.data.mesa1_boardtitle = self.widgets.mesa1_boardtitle.get_active_text()
  4312. def on_basicinfo_back(self, *args):
  4313. if self.data._re_editmode:
  4314. self.warning_dialog(_("You Have choosen to re-edit the current config, so you can not go to the\
  4315. new/modify page.\n Quit and reload PNCconf if you wish to build a new config."),True)
  4316. self.widgets.druid1.set_page(self.widgets.basicinfo)
  4317. return True
  4318. if not self.warning_dialog(_("If you can not go to the new/modify page your current data will be lost.\n\
  4319. Ok to reset data and start a new configuration?"),False):
  4320. self.widgets.druid1.set_page(self.widgets.basicinfo)
  4321. return True
  4322. def mesa_firmware_search(self,boardtitle,*args):
  4323. #TODO if no firm packages set up for internal data?
  4324. #TODO don't do this if the firmware is already loaded
  4325. self.pbar.set_text("Loading external firmware")
  4326. self.pbar.set_fraction(0)
  4327. self.window.show()
  4328. while gtk.events_pending():
  4329. gtk.main_iteration()
  4330. firmlist = []
  4331. for root, dirs, files in os.walk(firmdir):
  4332. folder = root.lstrip(firmdir)
  4333. if folder in mesablacklist:continue
  4334. if not folder == boardtitle:continue
  4335. for n,name in enumerate(files):
  4336. if name in mesablacklist:continue
  4337. if ".xml" in name:
  4338. #print name
  4339. temp = name.strip(".xml")
  4340. firmlist.append(temp)
  4341. dbg("\nXML list:%s"%firmlist,"firmname")
  4342. for n,currentfirm in enumerate(firmlist):
  4343. self.pbar.set_fraction(n*1.0/len(firmlist))
  4344. while gtk.events_pending():
  4345. gtk.main_iteration()
  4346. root = xml.etree.ElementTree.parse(os.path.join(firmdir,boardtitle,currentfirm+".xml"))
  4347. watchdog = encoder = resolver = pwmgen = led = muxedqcount = stepgen = tppwmgen = sserialports = sserialchannels = 0
  4348. numencoderpins = numpwmpins = 3; numstepperpins = 2; numttpwmpins = 0; numresolverpins = 10
  4349. temp = root.find("boardname").text
  4350. boardname = temp.lower()
  4351. dbg("\nBoard and firmwarename: %s %s\n"%( boardname, currentfirm), "firmraw")
  4352. maxgpio = int(root.find("iowidth").text) ; #print maxgpio
  4353. numcnctrs = int(root.find("ioports").text) ; #print numcnctrs
  4354. portwidth = int(root.find("portwidth").text)
  4355. placeholders = 24-portwidth
  4356. lowfreq = int(root.find("clocklow").text)/1000000 ; #print lowfreq
  4357. hifreq = int(root.find("clockhigh").text)/1000000 ; #print hifreq
  4358. modules = root.findall("//modules")[0]
  4359. if "7i43" in boardname:
  4360. driver = "hm2_7i43"
  4361. else:
  4362. driver = "hm2_pci"
  4363. for i,j in enumerate(modules):
  4364. k = modules[i].find("tagname").text
  4365. if k in ("Watchdog","WatchDog"):
  4366. l = modules[i].find("numinstances").text;#print l,k
  4367. watchdog = int(l)
  4368. elif k == "Encoder":
  4369. l = modules[i].find("numinstances").text;#print l,k
  4370. encoder = int(l)
  4371. elif k == "ResolverMod":
  4372. l = modules[i].find("numinstances").text;#print l,k
  4373. resolver = int(l)
  4374. elif k == "PWMGen":
  4375. l = modules[i].find("numinstances").text;#print l,k
  4376. pwmgen = int(l)
  4377. elif k == "LED":
  4378. l = modules[i].find("numinstances").text;#print l,k
  4379. led = int(l)
  4380. elif k == "MuxedQCount":
  4381. l = modules[i].find("numinstances").text;#print l,k
  4382. muxedqcount = int(l)
  4383. elif k == "StepGen":
  4384. l = modules[i].find("numinstances").text;#print l,k
  4385. stepgen = int(l)
  4386. elif k == "TPPWM":
  4387. l = modules[i].find("numinstances").text;#print l,k
  4388. tppwmgen = int(l)
  4389. elif k == "SSerial":
  4390. l = modules[i].find("numinstances").text;#print l,k
  4391. sserialports = int(l)
  4392. elif k == "None":
  4393. l = modules[i].find("numinstances").text;#print l,k
  4394. elif k in ("IOPort","AddrX","MuxedQCountSel"):
  4395. continue
  4396. else:
  4397. print "**** WARNING: Pncconf parsing firmware: tagname (%s) not reconized"% k
  4398. pins = root.findall("//pins")[0]
  4399. temppinlist = []
  4400. tempconlist = []
  4401. pinconvertenc = {"PHASE A":ENCA,"PHASE B":ENCB,"INDEX":ENCI,"INDEXMASK":ENCM,
  4402. "MUXED PHASE A":MXE0,"MUXED PHASE B":MXE1,"MUXED INDEX":MXEI,"MUXED INDEX MASK":MXEM,
  4403. "MUXED ENCODER SELECT 0":MXES,"MUXED ENCODER SELEC":MXES}
  4404. pinconvertresolver = {"RESOLVER POWER ENABLE":RESU,"RESOLVER SPIDI 0":RES0,"RESOLVER SPIDI 1":RES1,
  4405. "RESOLVER ADC CHANNEL 2":RES2,"RESOLVER ADC CHANNEL 1":RES3,"RESOLVER ADC CHANNEL 0":RES4,
  4406. "RESOLVER SPI CLK":RES5,"RESOLVER SPI CHIP SELECT":RESU,"RESOLVER PDMM":RESU,
  4407. "RESOLVER PDMP":RESU}
  4408. pinconvertstep = {"STEP":STEPA,"DIR":STEPB}
  4409. #"StepTable 2":STEPC,"StepTable 3":STEPD,"StepTable 4":STEPE,"StepTable 5":STEPF
  4410. pinconvertppwm = {"PWM/UP":PWMP,"DIR/DOWN":PWMD,"ENABLE":PWME}
  4411. pinconverttppwm = {"PWM A":TPPWMA,"PWM B":TPPWMB,"PWM C":TPPWMC,"PWM /A":TPPWMAN,"PWM /B":TPPWMBN,
  4412. "PWM /C":TPPWMCN,"FAULT":TPPWMF,"ENABLE":TPPWME}
  4413. pinconvertsserial = {"RXDATA1":RXDATA0,"TXDATA1":TXDATA0,"TXE1":TXEN0,"TXEN1":TXEN0,"RXDATA2":RXDATA1,"TXDATA2":TXDATA1,"TXE2":TXEN1,
  4414. "TXEN2":TXEN1,"RXDATA3":RXDATA2,"TXDATA3":TXDATA2,"TXE3":TXEN2,"TXEN3":TXEN2,"RXDATA4":RXDATA3,"TXDATA4":TXDATA3,
  4415. "TXE4":TXEN3,"TXEN4":TXEN3,"RXDATA5":RXDATA4,"TXDATA5":TXDATA4,"TXE5":TXEN4,"TXEN4":TXEN4,"RXDATA6":RXDATA5,
  4416. "TXDATA6":TXDATA5,"TXE6":TXEN5,"TXEN6":TXEN5,"RXDATA7":RXDATA6,"TXDATA7":TXDATA6,"TXE7":TXEN6,"TXEN7":TXEN6,
  4417. "RXDATA8":RXDATA7,"TXDATA8":TXDATA7,"TXE8":TXEN7,"TXEN8":TXEN7}
  4418. pinconvertnone = {"NOT USED":NUSED}
  4419. count = 0
  4420. for i,j in enumerate(pins):
  4421. temppinunit = []
  4422. temp = pins[i].find("connector").text
  4423. tempcon = int(temp.strip("P"))
  4424. tempfunc = pins[i].find("secondaryfunctionname").text
  4425. tempfunc = tempfunc.upper() # normalise capitalization: Peters XMLs are different from linuxcncs
  4426. if "(IN)" in tempfunc:
  4427. tempfunc = tempfunc.rstrip(" (IN)")
  4428. elif "(OUT" in tempfunc:
  4429. tempfunc = tempfunc.rstrip(" (OUT)")
  4430. convertedname = "Not Converted"
  4431. # this converts the XML file componennt names to pncconf's names
  4432. try:
  4433. modulename = pins[i].find("secondarymodulename").text
  4434. dbg("secondary modulename: %s, %s."%( tempfunc,modulename), "firmraw")
  4435. if modulename in ("Encoder","MuxedQCount","MuxedQCountSel","QCount"):
  4436. convertedname = pinconvertenc[tempfunc]
  4437. elif modulename == "ResolverMod":
  4438. convertedname = pinconvertresolver[tempfunc]
  4439. elif modulename == "PWMGen":
  4440. convertedname = pinconvertppwm[tempfunc]
  4441. elif modulename == "StepGen":
  4442. convertedname = pinconvertstep[tempfunc]
  4443. elif modulename == "TPPWM":
  4444. convertedname = pinconverttppwm[tempfunc]
  4445. elif modulename == "SSerial":
  4446. # this auto selects the sserial 7i76 mode 0 card for sserial 0 and 2
  4447. # as the 5i25/7i76 uses some of the sserial channels for it's pins.
  4448. if boardname == "5i25":
  4449. if "7i77_7i76" in currentfirm:
  4450. if tempfunc == "TXDATA1": convertedname = SS7I77M0
  4451. elif tempfunc == "TXDATA2": convertedname = SS7I77M1
  4452. elif tempfunc == "TXDATA4": convertedname = SS7I76M3
  4453. else: convertedname = pinconvertsserial[tempfunc]
  4454. #print "XML ",currentfirm, tempfunc,convertedname
  4455. elif "7i76x2" in currentfirm or "7i76x1" in currentfirm:
  4456. if tempfunc == "TXDATA1": convertedname = SS7I76M0
  4457. elif tempfunc == "TXDATA3": convertedname = SS7I76M2
  4458. else: convertedname = pinconvertsserial[tempfunc]
  4459. #print "XML ",currentfirm, tempfunc,convertedname
  4460. elif "7i77x2" in currentfirm or "7i77x1" in currentfirm:
  4461. if tempfunc == "TXDATA1": convertedname = SS7I77M0
  4462. elif tempfunc == "TXDATA2": convertedname = SS7I77M1
  4463. elif tempfunc == "TXDATA4": convertedname = SS7I77M3
  4464. elif tempfunc == "TXDATA5": convertedname = SS7I77M4
  4465. else: convertedname = pinconvertsserial[tempfunc]
  4466. #print "XML ",currentfirm, tempfunc,convertedname
  4467. else: convertedname = pinconvertsserial[tempfunc]
  4468. else:
  4469. convertedname = pinconvertsserial[tempfunc]
  4470. elif modulename == "None":
  4471. convertedname = pinconvertnone[tempfunc]
  4472. else: raise ValueError
  4473. except:
  4474. # must be GPIO pins if there is no secondary mudule name
  4475. # or if pinconvert fails eg. StepTable instance default to GPIO
  4476. temppinunit.append(GPIOI)
  4477. temppinunit.append(0) # 0 signals to pncconf that GPIO can changed to be input or output
  4478. else:
  4479. instance_num = int(pins[i].find("secondaryinstance").text)
  4480. # this is a workaround for the 7i77_7i776 firmware. it uses a mux encoder for the 7i76 but only uses half of it
  4481. # this is because of a limitation of hostmot2 - it can't have mux encoders and regular encoders
  4482. # so in pncconf we look for this and change it to a regular encoder.
  4483. if boardname == "5i25" and currentfirm == "7i77_7i76":
  4484. if modulename == "MuxedQCount" and instance_num == 3:
  4485. instance_num = 6
  4486. encoder =-1
  4487. if convertedname == MXE0: convertedname = ENCA
  4488. elif convertedname == MXE1: convertedname = ENCB
  4489. elif convertedname == MXEI: convertedname = ENCI
  4490. temppinunit.append(convertedname)
  4491. if tempfunc in("MUXED ENCODER SELECT 0") and instance_num == 6:
  4492. instance_num = 3
  4493. temppinunit.append(instance_num)
  4494. tempmod = pins[i].find("secondarymodulename").text
  4495. tempfunc = tempfunc.upper()# normalize capitalization
  4496. dbg("secondary modulename, function: %s, %s."%( tempmod,tempfunc), "firmraw")
  4497. if tempmod in("Encoder","MuxedQCount") and tempfunc in ("MUXED INDEX MASK (IN)","INDEXMASK (IN)"):
  4498. numencoderpins = 4
  4499. if tempmod =="SSerial" and tempfunc in ("TXDATA1","TXDATA2","TXDATA3","TXDATA4","TXDATA5","TXDATA6","TXDATA7","TXDATA8"):
  4500. sserialchannels +=1
  4501. dbg("temp: %s, converted name: %s. num %d"%( tempfunc,convertedname,instance_num), "firmraw")
  4502. if not tempcon in tempconlist:
  4503. tempconlist.append(tempcon)
  4504. temppinlist.append(temppinunit)
  4505. # add NONE place holders for boards with less then 24 pins per connector.
  4506. if not placeholders == 0 and i == (portwidth + count-1):
  4507. #print "loop %d"% i
  4508. count =+ portwidth
  4509. #print "count %d" % count
  4510. for k in range(0,placeholders):
  4511. #print "%d fill here with %d parts"% (k,placeholders)
  4512. temppinlist.append((NUSED,0))
  4513. temp = [boardtitle,boardname,currentfirm,boardtitle,driver,encoder + muxedqcount,
  4514. numencoderpins,resolver,numresolverpins,pwmgen,numpwmpins,
  4515. tppwmgen,numttpwmpins,stepgen,numstepperpins,sserialports,sserialchannels,0,0,0,0,0,0,0,0,watchdog,maxgpio,
  4516. lowfreq,hifreq,tempconlist]
  4517. for i in temppinlist:
  4518. temp.append(i)
  4519. if boardname == "5i25":
  4520. dbg("5i25 firmware:\n%s\n"%( temp), "5i25")
  4521. mesafirmwaredata.append(temp)
  4522. self.window.hide()
  4523. def on_machinename_changed(self, *args):
  4524. temp = self.widgets.machinename.get_text()
  4525. self.widgets.confdir.set_text("~/linuxcnc/configs/%s" % temp.replace(" ","_"))
  4526. def on_external_cntrl_prepare(self, *args):
  4527. self.data.help = "help-extcontrols.txt"
  4528. if self.data.multimpg :
  4529. self.widgets.multimpg.set_active(1)
  4530. else:
  4531. self.widgets.sharedmpg.set_active(1)
  4532. if self.data.fo_usempg :
  4533. self.widgets.fo_usempg.set_active(1)
  4534. else:
  4535. self.widgets.fo_useswitch.set_active(1)
  4536. if self.data.mvo_usempg :
  4537. self.widgets.mvo_usempg.set_active(1)
  4538. else:
  4539. self.widgets.mvo_useswitch.set_active(1)
  4540. if self.data.so_usempg :
  4541. self.widgets.so_usempg.set_active(1)
  4542. else:
  4543. self.widgets.so_useswitch.set_active(1)
  4544. self.widgets.jograpidrate.set_value(self.data.jograpidrate)
  4545. self.widgets.singlejogbuttons.set_active(self.data.singlejogbuttons)
  4546. self.widgets.multijogbuttons.set_active(self.data.multijogbuttons)
  4547. self.widgets.externalmpg.set_active(self.data.externalmpg)
  4548. self.widgets.externaljog.set_active(self.data.externaljog)
  4549. self.widgets.externalfo.set_active(self.data.externalfo)
  4550. self.widgets.externalmvo.set_active(self.data.externalmvo)
  4551. self.widgets.externalso.set_active(self.data.externalso)
  4552. self.widgets.sharedmpg.set_active(self.data.sharedmpg)
  4553. self.widgets.multimpg.set_active(self.data.multimpg)
  4554. self.widgets.incrselect.set_active(self.data.incrselect)
  4555. for i in ("mpg","fo","so","mvo"):
  4556. self.widgets[i+"debounce"].set_active(self.data[i+"debounce"])
  4557. self.widgets[i+"debouncetime"].set_value(self.data[i+"debouncetime"])
  4558. self.widgets[i+"graycode"].set_active(self.data[i+"graycode"])
  4559. self.widgets[i+"ignorefalse"].set_active(self.data[i+"ignorefalse"])
  4560. if self.data.units == _IMPERIAL :
  4561. tempunits = "in"
  4562. else:
  4563. tempunits = "mm"
  4564. for i in range(0,16):
  4565. self.widgets["foincrvalue"+str(i)].set_value(self.data["foincrvalue"+str(i)])
  4566. self.widgets["mvoincrvalue"+str(i)].set_value(self.data["mvoincrvalue"+str(i)])
  4567. self.widgets["soincrvalue"+str(i)].set_value(self.data["soincrvalue"+str(i)])
  4568. self.widgets["mpgincr"+str(i)].set_text(tempunits)
  4569. self.widgets.jograpidunits.set_text(tempunits+" / min")
  4570. for i in range(0,4):
  4571. self.widgets["joystickjograpidunits%d"%i].set_text(tempunits+" / min")
  4572. for i in range(0,8):
  4573. self.widgets["mpgincrvalue"+str(i)].set_value(self.data["mpgincrvalue"+str(i)])
  4574. self.widgets.joystickjog.set_active(self.data.joystickjog)
  4575. self.widgets.usbdevicename.set_text(self.data.usbdevicename)
  4576. for i in range(0,4):
  4577. self.widgets["joystickjograpidrate%d"%i].set_value(self.data["joystickjograpidrate%d"%i])
  4578. for temp in ("joycmdxpos","joycmdxneg","joycmdypos","joycmdyneg","joycmdzpos","joycmdzneg","joycmdapos","joycmdaneg","joycmdrapida","joycmdrapidb",
  4579. "joycmdanalogx","joycmdanalogy","joycmdanalogz","joycmdanaloga"):
  4580. self.widgets[temp].set_text(self.data[temp])
  4581. def on_joystickjog_toggled(self, *args):
  4582. if self.widgets.externaljog.get_active() == True and self.widgets.joystickjog.get_active() == True:
  4583. self.widgets.externaljog.set_active(False)
  4584. self.on_external_options_toggled()
  4585. def on_externaljog_toggled(self, *args):
  4586. if self.widgets.joystickjog.get_active() == True and self.widgets.externaljog.get_active() == True:
  4587. self.widgets.joystickjog.set_active(False)
  4588. self.on_external_options_toggled()
  4589. def on_external_options_toggled(self, *args):
  4590. self.widgets.externaljogbox.set_sensitive(self.widgets.externaljog.get_active())
  4591. self.widgets.externalmpgbox.set_sensitive(self.widgets.externalmpg.get_active())
  4592. self.widgets.externalfobox.set_sensitive(self.widgets.externalfo.get_active())
  4593. self.widgets.externalmvobox.set_sensitive(self.widgets.externalmvo.get_active())
  4594. self.widgets.externalsobox.set_sensitive(self.widgets.externalso.get_active())
  4595. self.widgets.foexpander.set_sensitive(self.widgets.fo_useswitch.get_active())
  4596. self.widgets.mvoexpander.set_sensitive(self.widgets.mvo_useswitch.get_active())
  4597. self.widgets.soexpander.set_sensitive(self.widgets.so_useswitch.get_active())
  4598. self.widgets.joystickjogbox.set_sensitive(self.widgets.joystickjog.get_active())
  4599. i = self.widgets.incrselect.get_active()
  4600. for j in range(1,16):
  4601. self.widgets["incrlabel%d"% j].set_sensitive(i)
  4602. self.widgets["mpgincrvalue%d"% j].set_sensitive(i)
  4603. self.widgets["mpgincr%d"% j].set_sensitive(i)
  4604. def on_addrule_clicked(self, *args):
  4605. text = []
  4606. sourcefile = "/tmp/"
  4607. if os.path.exists("/etc/udev/rules.d/50-LINUXCNC-general.rules"):
  4608. text.append( "General rule already exists\n")
  4609. else:
  4610. text.append("adding a general rule first\nso your device will be found\n")
  4611. filename = os.path.join(sourcefile, "LINUXCNCtempGeneral.rules")
  4612. file = open(filename, "w")
  4613. print >>file, ("# This is a rule for LinuxCNC's hal_input\n")
  4614. print >>file, ("""SUBSYSTEM="input", MODE="0660", GROUP="plugdev" """)
  4615. file.close()
  4616. p=os.popen("gksudo cp %sLINUXCNCtempGeneral.rules /etc/udev/rules.d/50-LINUXCNC-general.rules"% sourcefile )
  4617. time.sleep(.1)
  4618. p.flush()
  4619. p.close()
  4620. os.remove('%sLINUXCNCtempGeneral.rules'% sourcefile)
  4621. text.append(("disconect USB device please\n"))
  4622. if not self.warning_dialog("\n".join(text),False):return
  4623. os.popen('less /proc/bus/input/devices >> %sLINUXCNCnojoytemp.txt'% sourcefile)
  4624. text = ["Plug in USB device please"]
  4625. if not self.warning_dialog("\n".join(text),False):return
  4626. time.sleep(1)
  4627. os.popen('less /proc/bus/input/devices >> %sLINUXCNCjoytemp.txt'% sourcefile).read()
  4628. diff = os.popen (" less /proc/bus/input/devices | diff %sLINUXCNCnojoytemp.txt %sLINUXCNCjoytemp.txt "%(sourcefile, sourcefile) ).read()
  4629. self.widgets.helpwindow.set_title(_("USB device Info Search"))
  4630. os.remove('%sLINUXCNCnojoytemp.txt'% sourcefile)
  4631. os.remove('%sLINUXCNCjoytemp.txt'% sourcefile)
  4632. if diff =="":
  4633. text = ["No new USB device found"]
  4634. if not self.warning_dialog("\n".join(text),True):return
  4635. else:
  4636. textbuffer = self.widgets.textoutput.get_buffer()
  4637. try :
  4638. textbuffer.set_text(diff)
  4639. self.widgets.helpnotebook.set_current_page(2)
  4640. self.widgets.helpwindow.show_all()
  4641. except:
  4642. text = _("USB device page is unavailable\n")
  4643. self.warning_dialog(text,True)
  4644. linelist = diff.split("\n")
  4645. for i in linelist:
  4646. if "Name" in i:
  4647. temp = i.split("\"")
  4648. name = temp[1]
  4649. temp = name.split(" ")
  4650. self.widgets.usbdevicename.set_text(temp[0])
  4651. infolist = diff.split()
  4652. for i in infolist:
  4653. if "Vendor" in i:
  4654. temp = i.split("=")
  4655. vendor = temp[1]
  4656. if "Product" in i:
  4657. temp = i.split("=")
  4658. product = temp[1]
  4659. text =[ "Vendor = %s\n product = %s\n name = %s\nadding specific rule"%(vendor,product,name)]
  4660. if not self.warning_dialog("\n".join(text),False):return
  4661. tempname = sourcefile+"LINUXCNCtempspecific.rules"
  4662. file = open(tempname, "w")
  4663. print >>file, ("# This is a rule for LINUXCNC's hal_input\n")
  4664. print >>file, ("# For devicename=%s\n"% name)
  4665. print >>file, ("""SYSFS{idProduct}=="%s", SYSFS{idVendor}=="%s", MODE="0660", GROUP="plugdev" """%(product,vendor))
  4666. file.close()
  4667. # remove illegal filename characters
  4668. for i in ("(",")"):
  4669. temp = name.replace(i,"")
  4670. name = temp
  4671. newname = "50-LINUXCNC-%s.rules"% name.replace(" ","_")
  4672. os.popen("gksudo cp %s /etc/udev/rules.d/%s"% (tempname,newname) )
  4673. time.sleep(1)
  4674. os.remove('%sLINUXCNCtempspecific.rules'% sourcefile)
  4675. text = ["Please unplug and plug in your device again"]
  4676. if not self.warning_dialog("\n".join(text),True):return
  4677. def on_joysticktest_clicked(self, *args):
  4678. halrun = subprocess.Popen("halrun -I ", shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE )
  4679. #print "requested devicename = ",self.widgets.usbdevicename.get_text()
  4680. halrun.stdin.write("loadusr hal_input -W -KRAL +%s\n"% self.widgets.usbdevicename.get_text())
  4681. halrun.stdin.write("loadusr halmeter -g 0 500\n")
  4682. time.sleep(1.5)
  4683. halrun.stdin.write("show pin\n")
  4684. self.warning_dialog("Close me When done.\n",True)
  4685. halrun.stdin.write("exit\n")
  4686. output = halrun.communicate()[0]
  4687. temp2 = output.split(" ")
  4688. temp=[]
  4689. for i in temp2:
  4690. if i =="": continue
  4691. temp.append(i)
  4692. buttonlist=""
  4693. for index,i in enumerate(temp):
  4694. if "bit" in i and "OUT" in temp[index+1]:
  4695. buttonlist = buttonlist + " Digital: %s"% ( temp[index+3] )
  4696. if "float" in i and "OUT" in temp[index+1]:
  4697. buttonlist = buttonlist + " Analog: %s"% ( temp[index+3] )
  4698. if buttonlist =="": return
  4699. textbuffer = self.widgets.textoutput.get_buffer()
  4700. try :
  4701. textbuffer.set_text(buttonlist)
  4702. self.widgets.helpnotebook.set_current_page(2)
  4703. self.widgets.helpwindow.show_all()
  4704. except:
  4705. text = _("Pin names are unavailable\n")
  4706. self.warning_dialog(text,True)
  4707. def on_joysearch_clicked(self, *args):
  4708. flag = False
  4709. textbuffer = self.widgets.textoutput.get_buffer()
  4710. textbuffer.set_text("Searching for device rules in folder: /etc/udev/rules.d\n\n")
  4711. for entry in os.listdir("/etc/udev/rules.d"):
  4712. if fnmatch.fnmatch( entry,"50-LINUXCNC-*"):
  4713. temp = open("/etc/udev/rules.d/" + entry, "r").read()
  4714. templist = temp.split("\n")
  4715. for i in templist:
  4716. if "devicename=" in i:
  4717. flag = True
  4718. temp = i.split("=")
  4719. name = temp[1]
  4720. try:
  4721. textbuffer.insert_at_cursor( "File name: %s\n"% entry)
  4722. textbuffer.insert_at_cursor( "Device name: %s\n\n"% name)
  4723. self.widgets.helpnotebook.set_current_page(2)
  4724. self.widgets.helpwindow.show_all()
  4725. except:
  4726. text = _("Device names are unavailable\n")
  4727. self.warning_dialog(text,True)
  4728. if flag == False:
  4729. text = _("No Pncconf made device rules were found\n")
  4730. textbuffer.insert_at_cursor(text)
  4731. self.warning_dialog(text,True)
  4732. def on_external_cntrl_next(self, *args):
  4733. self.data.multimpg = self.widgets.multimpg.get_active()
  4734. self.data.fo_usempg = self.widgets.fo_usempg.get_active()
  4735. self.data.fo_useswitch = self.widgets.fo_useswitch.get_active()
  4736. self.data.mvo_usempg = self.widgets.mvo_usempg.get_active()
  4737. self.data.mvo_useswitch = self.widgets.mvo_useswitch.get_active()
  4738. self.data.so_usempg = self.widgets.so_usempg.get_active()
  4739. self.data.so_useswitch = self.widgets.so_useswitch.get_active()
  4740. self.data.jograpidrate = self.widgets.jograpidrate.get_value()
  4741. self.data.singlejogbuttons = self.widgets.singlejogbuttons.get_active()
  4742. self.data.multijogbuttons = self.widgets.multijogbuttons.get_active()
  4743. self.data.externalmpg = self.widgets.externalmpg.get_active()
  4744. self.data.externaljog = self.widgets.externaljog.get_active()
  4745. self.data.externalfo = self.widgets.externalfo.get_active()
  4746. self.data.externalso = self.widgets.externalso.get_active()
  4747. self.data.externalmvo = self.widgets.externalmvo.get_active()
  4748. self.data.sharedmpg = self.widgets.sharedmpg.get_active()
  4749. self.data.multimpg = self.widgets.multimpg.get_active()
  4750. self.data.incrselect = self.widgets.incrselect.get_active()
  4751. for i in ("mpg","fo","so","mvo"):
  4752. self.data[i+"debounce"] = self.widgets[i+"debounce"].get_active()
  4753. self.data[i+"debouncetime"] = self.widgets[i+"debouncetime"].get_value()
  4754. self.data[i+"graycode"] = self.widgets[i+"graycode"].get_active()
  4755. self.data[i+"ignorefalse"] = self.widgets[i+"ignorefalse"].get_active()
  4756. for i in range (0,16):
  4757. self.data["foincrvalue"+str(i)] = self.widgets["foincrvalue"+str(i)].get_value()
  4758. self.data["mvoincrvalue"+str(i)] = self.widgets["mvoincrvalue"+str(i)].get_value()
  4759. self.data["soincrvalue"+str(i)] = self.widgets["soincrvalue"+str(i)].get_value()
  4760. self.data["mpgincrvalue"+str(i)] = self.widgets["mpgincrvalue"+str(i)].get_value()
  4761. self.data.usbdevicename = self.widgets.usbdevicename.get_text()
  4762. self.data.joystickjog = self.widgets.joystickjog.get_active()
  4763. for i in range(0,4):
  4764. self.data["joystickjograpidrate%d"%i] = self.widgets["joystickjograpidrate%d"%i].get_value()
  4765. for temp in ("joycmdxpos","joycmdxneg","joycmdypos","joycmdyneg","joycmdzpos","joycmdzneg","joycmdapos",
  4766. "joycmdaneg","joycmdrapida","joycmdrapidb","joycmdanalogx","joycmdanalogy","joycmdanalogz","joycmdanaloga"):
  4767. self.data[temp] = self.widgets[temp].get_text()
  4768. self.widgets.joyjogexpander.set_expanded(False)
  4769. def on_GUI_config_prepare(self, *args):
  4770. self.data.help = "help-gui.txt"
  4771. self.widgets.pyvcp.set_active(self.data.pyvcp)
  4772. self.on_pyvcp_toggled()
  4773. self.widgets.pyvcpexist.set_active(self.data.pyvcpexist)
  4774. self.widgets.pyvcp1.set_active(self.data.pyvcp1)
  4775. self.widgets.pyvcpblank.set_active(self.data.pyvcpblank)
  4776. self.widgets.default_linear_velocity.set_value( self.data.default_linear_velocity*60)
  4777. self.widgets.max_spindle_override.set_value( self.data.max_spindle_override*100)
  4778. self.widgets.min_spindle_override.set_value( self.data.min_spindle_override*100)
  4779. self.widgets.max_linear_velocity.set_value( self.data.max_linear_velocity*60)
  4780. self.widgets.min_linear_velocity.set_value( self.data.min_linear_velocity*60)
  4781. self.widgets.default_angular_velocity.set_value( self.data.default_angular_velocity*60)
  4782. self.widgets.max_angular_velocity.set_value( self.data.max_angular_velocity*60)
  4783. self.widgets.min_angular_velocity.set_value( self.data.min_angular_velocity*60)
  4784. self.widgets.editor.set_text(self.data.editor)
  4785. if self.data.units == _IMPERIAL :
  4786. temp = self.data.increments_imperial
  4787. tempunits = "in / min"
  4788. else:
  4789. temp = self.data.increments_metric
  4790. tempunits = "mm / min"
  4791. self.widgets.increments.set_text(temp)
  4792. for i in (0,1,2):
  4793. self.widgets["velunits"+str(i)].set_text(tempunits)
  4794. self.widgets.position_offset.set_active(self.data.position_offset)
  4795. self.widgets.position_feedback.set_active(self.data.position_feedback)
  4796. self.widgets.geometry.set_text(self.data.geometry)
  4797. self.widgets.pyvcpconnect.set_active(self.data.pyvcpconnect)
  4798. self.widgets.require_homing.set_active(self.data.require_homing)
  4799. self.widgets.individual_homing.set_active(self.data.individual_homing)
  4800. self.widgets.restore_joint_position.set_active(self.data.restore_joint_position)
  4801. self.widgets.random_toolchanger.set_active(self.data.random_toolchanger)
  4802. self.widgets.raise_z_on_toolchange.set_active(self.data.raise_z_on_toolchange)
  4803. self.widgets.allow_spindle_on_toolchange.set_active(self.data.allow_spindle_on_toolchange)
  4804. self.widgets.toolchangeprompt.set_active(self.data.toolchangeprompt)
  4805. # This reads the Touchy preference file directly
  4806. tempdict = {"touchyabscolor":"abs_textcolor","touchyrelcolor":"rel_textcolor",
  4807. "touchydtgcolor":"dtg_textcolor","touchyerrcolor":"err_textcolor"}
  4808. for key,value in tempdict.iteritems():
  4809. data = prefs.getpref(value, 'default', str)
  4810. if data == "default":
  4811. self.widgets[key].set_active(False)
  4812. else:
  4813. self.widgets[key].set_active(True)
  4814. self.widgets[key+"button"].set_color(gtk.gdk.color_parse(data))
  4815. self.widgets.touchyforcemax.set_active(bool(prefs.getpref('window_force_max')))
  4816. for i in ("gladevcp","gladesample","gladeexists","spindlespeedbar","spindleatspeed","gladevcpforcemax",
  4817. "zerox","zeroy","zeroz","zeroa","autotouchz","centerembededgvcp","sideembededgvcp","standalonegvcp",
  4818. "gladevcpposition","gladevcpsize","pyvcpposition","pyvcpsize","axisforcemax"):
  4819. self.widgets[i].set_active(self.data[i])
  4820. for i in ("maxspeeddisplay","gladevcpwidth","gladevcpheight","gladevcpxpos","gladevcpypos",
  4821. "pyvcpwidth","pyvcpheight","pyvcpxpos","pyvcpypos"):
  4822. self.widgets[i].set_value(self.data[i])
  4823. for i in ("touchy","axis"):
  4824. self.widgets[i+"size"].set_active(self.data[i+"size"][0])
  4825. self.widgets[i+"width"].set_value(self.data[i+"size"][1])
  4826. self.widgets[i+"height"].set_value(self.data[i+"size"][2])
  4827. self.widgets[i+"position"].set_active(self.data[i+"position"][0])
  4828. self.widgets[i+"xpos"].set_value(self.data[i+"position"][1])
  4829. self.widgets[i+"ypos"].set_value(self.data[i+"position"][2])
  4830. if os.path.exists(themedir):
  4831. for i in ("gladevcptheme","touchytheme"):
  4832. if i == "gladevcptheme": data = self.data[i]
  4833. else: data = prefs.getpref('gtk_theme', 'Follow System Theme', str)
  4834. model = self.widgets[i].get_model()
  4835. model.clear()
  4836. model.append(("Follow System Theme",))
  4837. temp = 0
  4838. names = os.listdir(themedir)
  4839. names.sort()
  4840. for search,dirs in enumerate(names):
  4841. model.append((dirs,))
  4842. if dirs == data:
  4843. temp = search+1
  4844. self.widgets[i].set_active(temp)
  4845. self.on_gladevcp_toggled()
  4846. def on_GUI_config_next(self, *args):
  4847. # Sanity checks
  4848. if not self.widgets.createconfig.get_active():
  4849. if self.widgets.gladevcp.get_active() and self.widgets.gladesample.get_active():
  4850. if os.path.exists(os.path.expanduser("~/linuxcnc/configs/%s/gvcp-panel.ui" % self.data.machinename)):
  4851. if not self.warning_dialog(_("OK to replace existing glade panel ?\
  4852. \nIt will be renamed and added to 'backups' folder.\n Clicking 'existing custom program' will avoid this warning, but \
  4853. if you change related options later -such as spindle feedback- the HAL connection will not update"),False):
  4854. return True
  4855. if self.widgets.pyvcp.get_active() and not self.widgets.pyvcpexist.get_active():
  4856. if os.path.exists(os.path.expanduser("~/linuxcnc/configs/%s/pyvcp-panel.xml" % self.data.machinename)):
  4857. if not self.warning_dialog(_("OK to replace existing custom pyvcp panel?\
  4858. \nExisting pyvcp-panel.xml will be renamed and added to 'backups' folder\n\
  4859. Clicking 'existing custom program' will aviod this warning. "),False):
  4860. return True
  4861. self.data.default_linear_velocity = self.widgets.default_linear_velocity.get_value()/60
  4862. self.data.max_spindle_override = self.widgets.max_spindle_override.get_value()/100
  4863. self.data.min_spindle_override = self.widgets.min_spindle_override.get_value()/100
  4864. self.data.max_linear_velocity = self.widgets.max_linear_velocity.get_value()/60
  4865. self.data.min_linear_velocity = self.widgets.min_linear_velocity.get_value()/60
  4866. self.data.default_angular_velocity = self.widgets.default_angular_velocity.get_value()/60
  4867. self.data.max_angular_velocity = self.widgets.max_angular_velocity.get_value()/60
  4868. self.data.min_angular_velocity = self.widgets.min_angular_velocity.get_value()/60
  4869. self.data.editor = self.widgets.editor.get_text()
  4870. if self.data.units == _IMPERIAL :self.data.increments_imperial = self.widgets.increments.get_text()
  4871. else:self.data.increments_metric = self.widgets.increments.get_text()
  4872. self.data.geometry = self.widgets.geometry.get_text()
  4873. self.data.position_offset = self.widgets.position_offset.get_active()
  4874. self.data.position_feedback = self.widgets.position_feedback.get_active()
  4875. self.data.require_homing = self.widgets.require_homing.get_active()
  4876. self.data.individual_homing = self.widgets.individual_homing.get_active()
  4877. self.data.restore_joint_position = self.widgets.restore_joint_position.get_active()
  4878. self.data.random_toolchanger = self.widgets.random_toolchanger.get_active()
  4879. self.data.raise_z_on_toolchange = self.widgets.raise_z_on_toolchange.get_active()
  4880. self.data.allow_spindle_on_toolchange = self.widgets.allow_spindle_on_toolchange.get_active()
  4881. self.data.toolchangeprompt = self.widgets.toolchangeprompt.get_active()
  4882. self.data.pyvcpblank = self.widgets.pyvcpblank.get_active()
  4883. self.data.pyvcp1 = self.widgets.pyvcp1.get_active()
  4884. self.data.pyvcpexist = self.widgets.pyvcpexist.get_active()
  4885. self.data.pyvcp = self.widgets.pyvcp.get_active()
  4886. self.data.pyvcpconnect = self.widgets.pyvcpconnect.get_active()
  4887. if self.data.pyvcp == True:
  4888. if self.widgets.pyvcpblank.get_active() == True:
  4889. self.data.pyvcpname = "blank.xml"
  4890. self.data.pyvcphaltype = 0
  4891. if self.widgets.pyvcp1.get_active() == True:
  4892. self.data.pyvcpname = "spindle.xml"
  4893. self.data.pyvcphaltype = 1
  4894. if self.widgets.pyvcpexist.get_active() == True:
  4895. self.data.pyvcpname = "pyvcp-panel.xml"
  4896. for i in ("touchyabscolor","touchyrelcolor","touchydtgcolor","touchyerrcolor"):
  4897. if not self.widgets[i].get_active():
  4898. self.data[i] = "default"
  4899. else:
  4900. self.data[i] = str(self.widgets[i+"button"].get_color())
  4901. self.data.touchytheme = self.widgets.touchytheme.get_active_text()
  4902. self.data.touchyforcemax = self.widgets.touchyforcemax.get_active()
  4903. for i in ("gladevcp","gladesample","spindlespeedbar","spindleatspeed","gladevcpforcemax",
  4904. "centerembededgvcp","sideembededgvcp","standalonegvcp","gladeexists",
  4905. "gladevcpposition","gladevcpsize","pyvcpposition","pyvcpsize","axisforcemax","autotouchz"):
  4906. self.data[i] = self.widgets[i].get_active()
  4907. # set HALUI commands ( on advanced page) based on the user requested glade buttons
  4908. i = self.data.gladevcphaluicmds = 0
  4909. for temp in(("zerox","G10 L20 P0 X0 ( Set X to zero )"),("zeroy","G10 L20 P0 Y0 ( Set Y to zero )"),
  4910. ("zeroz","G10 L20 P0 Z0 ( Set Z to zero )"),("zeroa","G10 L20 P0 A0 ( Set A to zero )")):
  4911. self.data[temp[0]] = self.widgets[temp[0]].get_active()
  4912. if self.data[temp[0]]:
  4913. self.data.halui = True
  4914. self.data["halui_cmd%d"% i] = temp[1]
  4915. i += 1
  4916. self.data.gladevcphaluicmds += 1
  4917. for i in ("maxspeeddisplay","gladevcpwidth","gladevcpheight","gladevcpxpos","gladevcpypos",
  4918. "pyvcpwidth","pyvcpheight","pyvcpxpos","pyvcpypos"):
  4919. self.data[i] = self.widgets[i].get_value()
  4920. for i in ("touchy","axis"):
  4921. self.data[i+"size"][0] = self.widgets[i+"size"].get_active()
  4922. self.data[i+"size"][1] = self.widgets[i+"width"].get_value()
  4923. self.data[i+"size"][2] = self.widgets[i+"height"].get_value()
  4924. self.data[i+"position"][0] = self.widgets[i+"position"].get_active()
  4925. self.data[i+"position"][1] = self.widgets[i+"xpos"].get_value()
  4926. self.data[i+"position"][2] = self.widgets[i+"ypos"].get_value()
  4927. self.data.gladevcptheme = self.widgets.gladevcptheme.get_active_text()
  4928. # make sure there is a copy of the choosen gladevcp panel in /tmp/
  4929. # We will copy it later into our config folder
  4930. self.gladevcptestpanel(self)
  4931. if self.widgets.autotouchz.get_active():
  4932. self.data.classicladder = True
  4933. if not self.widgets.ladderexist.get_active():
  4934. self.widgets.laddertouchz.set_active(True)
  4935. if not self.data.number_mesa:
  4936. self.widgets.druid1.set_page(self.widgets.pp1pport)
  4937. return True
  4938. def do_exclusive_inputs(self, pin):
  4939. if self.in_pport_prepare: return
  4940. exclusive = {
  4941. HOME_X: (MAX_HOME_X, MIN_HOME_X, BOTH_HOME_X, ALL_HOME),
  4942. HOME_Y: (MAX_HOME_Y, MIN_HOME_Y, BOTH_HOME_Y, ALL_HOME),
  4943. HOME_Z: (MAX_HOME_Z, MIN_HOME_Z, BOTH_HOME_Z, ALL_HOME),
  4944. HOME_A: (MAX_HOME_A, MIN_HOME_A, BOTH_HOME_A, ALL_HOME),
  4945. MAX_HOME_X: (HOME_X, MIN_HOME_X, MAX_HOME_X, BOTH_HOME_X, ALL_LIMIT, ALL_HOME),
  4946. MAX_HOME_Y: (HOME_Y, MIN_HOME_Y, MAX_HOME_Y, BOTH_HOME_Y, ALL_LIMIT, ALL_HOME),
  4947. MAX_HOME_Z: (HOME_Z, MIN_HOME_Z, MAX_HOME_Z, BOTH_HOME_Z, ALL_LIMIT, ALL_HOME),
  4948. MAX_HOME_A: (HOME_A, MIN_HOME_A, MAX_HOME_A, BOTH_HOME_A, ALL_LIMIT, ALL_HOME),
  4949. MIN_HOME_X: (HOME_X, MAX_HOME_X, BOTH_HOME_X, ALL_LIMIT, ALL_HOME),
  4950. MIN_HOME_Y: (HOME_Y, MAX_HOME_Y, BOTH_HOME_Y, ALL_LIMIT, ALL_HOME),
  4951. MIN_HOME_Z: (HOME_Z, MAX_HOME_Z, BOTH_HOME_Z, ALL_LIMIT, ALL_HOME),
  4952. MIN_HOME_A: (HOME_A, MAX_HOME_A, BOTH_HOME_A, ALL_LIMIT, ALL_HOME),
  4953. BOTH_HOME_X: (HOME_X, MAX_HOME_X, MIN_HOME_X, ALL_LIMIT, ALL_HOME),
  4954. BOTH_HOME_Y: (HOME_Y, MAX_HOME_Y, MIN_HOME_Y, ALL_LIMIT, ALL_HOME),
  4955. BOTH_HOME_Z: (HOME_Z, MAX_HOME_Z, MIN_HOME_Z, ALL_LIMIT, ALL_HOME),
  4956. BOTH_HOME_A: (HOME_A, MAX_HOME_A, MIN_HOME_A, ALL_LIMIT, ALL_HOME),
  4957. MIN_X: (BOTH_X, BOTH_HOME_X, MIN_HOME_X, ALL_LIMIT),
  4958. MIN_Y: (BOTH_Y, BOTH_HOME_Y, MIN_HOME_Y, ALL_LIMIT),
  4959. MIN_Z: (BOTH_Z, BOTH_HOME_Z, MIN_HOME_Z, ALL_LIMIT),
  4960. MIN_A: (BOTH_A, BOTH_HOME_A, MIN_HOME_A, ALL_LIMIT),
  4961. MAX_X: (BOTH_X, BOTH_HOME_X, MIN_HOME_X, ALL_LIMIT),
  4962. MAX_Y: (BOTH_Y, BOTH_HOME_Y, MIN_HOME_Y, ALL_LIMIT),
  4963. MAX_Z: (BOTH_Z, BOTH_HOME_Z, MIN_HOME_Z, ALL_LIMIT),
  4964. MAX_A: (BOTH_A, BOTH_HOME_A, MIN_HOME_A, ALL_LIMIT),
  4965. BOTH_X: (MIN_X, MAX_X, MIN_HOME_X, MAX_HOME_X, BOTH_HOME_X, ALL_LIMIT),
  4966. BOTH_Y: (MIN_Y, MAX_Y, MIN_HOME_Y, MAX_HOME_Y, BOTH_HOME_Y, ALL_LIMIT),
  4967. BOTH_Z: (MIN_Z, MAX_Z, MIN_HOME_Z, MAX_HOME_Z, BOTH_HOME_Z, ALL_LIMIT),
  4968. BOTH_A: (MIN_A, MAX_A, MIN_HOME_A, MAX_HOME_A, BOTH_HOME_A, ALL_LIMIT),
  4969. ALL_LIMIT: (
  4970. MIN_X, MAX_X, BOTH_X, MIN_HOME_X, MAX_HOME_X, BOTH_HOME_X,
  4971. MIN_Y, MAX_Y, BOTH_Y, MIN_HOME_Y, MAX_HOME_Y, BOTH_HOME_Y,
  4972. MIN_Z, MAX_Z, BOTH_Z, MIN_HOME_Z, MAX_HOME_Z, BOTH_HOME_Z,
  4973. MIN_A, MAX_A, BOTH_A, MIN_HOME_A, MAX_HOME_A, BOTH_HOME_A),
  4974. ALL_HOME: (
  4975. HOME_X, MIN_HOME_X, MAX_HOME_X, BOTH_HOME_X,
  4976. HOME_Y, MIN_HOME_Y, MAX_HOME_Y, BOTH_HOME_Y,
  4977. HOME_Z, MIN_HOME_Z, MAX_HOME_Z, BOTH_HOME_Z,
  4978. HOME_A, MIN_HOME_A, MAX_HOME_A, BOTH_HOME_A),
  4979. }
  4980. p = 'pp1Ipin%d' % pin
  4981. v = self.widgets[p].get_active()
  4982. ex = exclusive.get(hal_input_names[v], ())
  4983. for pin1 in (10,11,12,13,15):
  4984. if pin1 == pin: continue
  4985. p = 'pp1Ipin%d' % pin1
  4986. v1 = hal_input_names[self.widgets[p].get_active()]
  4987. if v1 in ex or v1 == v:
  4988. self.widgets[p].set_active(hal_input_names.index(UNUSED_INPUT))
  4989. def on_pin10_changed(self, *args):
  4990. self.do_exclusive_inputs(10)
  4991. def on_pin11_changed(self, *args):
  4992. self.do_exclusive_inputs(11)
  4993. def on_pin12_changed(self, *args):
  4994. self.do_exclusive_inputs(12)
  4995. def on_pin13_changed(self, *args):
  4996. self.do_exclusive_inputs(13)
  4997. def on_pin15_changed(self, *args):
  4998. self.do_exclusive_inputs(15)
  4999. def on_mesa_boardname_changed(self, widget,boardnum):
  5000. #print "**** INFO boardname changed"
  5001. model = self.widgets["mesa%d_boardtitle"% boardnum].get_model()
  5002. active = self.widgets["mesa%d_boardtitle"% boardnum].get_active()
  5003. if active < 0:
  5004. title = None
  5005. else: title = model[active][0]
  5006. if title == None:return
  5007. self.widgets["mesa%dtitle"%boardnum].set_text(title)
  5008. model = self.widgets["mesa%d_firmware"% boardnum].get_model()
  5009. model.clear()
  5010. for search, item in enumerate(mesafirmwaredata):
  5011. d = mesafirmwaredata[search]
  5012. if not d[_BOARDTITLE] == title:continue
  5013. model.append((d[_FIRMWARE],))
  5014. break
  5015. self.widgets["mesa%d_firmware"% boardnum].set_active(0)
  5016. #print "boardname-" + d[_BOARDNAME]
  5017. if "7i43" in d[_BOARDNAME] :
  5018. self.widgets["mesa%d_parportaddrs"% boardnum].set_sensitive(1)
  5019. else:
  5020. self.widgets["mesa%d_parportaddrs"% boardnum].set_sensitive(0)
  5021. self.on_mesa_firmware_changed(self,boardnum)
  5022. def on_mesa_firmware_changed(self, widget,boardnum):
  5023. model = self.widgets["mesa%d_boardtitle"% boardnum].get_model()
  5024. active = self.widgets["mesa%d_boardtitle"% boardnum].get_active()
  5025. if active < 0:
  5026. title = None
  5027. else: title = model[active][0]
  5028. firmware = self.widgets["mesa%d_firmware"% boardnum].get_active_text()
  5029. for search, item in enumerate(mesafirmwaredata):
  5030. d = mesafirmwaredata[search]
  5031. if not d[_BOARDTITLE] == title:continue
  5032. if d[_FIRMWARE] == firmware:
  5033. self.widgets["mesa%d_numof_encodergens"%boardnum].set_range(0,d[_MAXENC])
  5034. self.widgets["mesa%d_numof_encodergens"% boardnum].set_value(d[_MAXENC])
  5035. self.widgets["mesa%d_numof_pwmgens"% boardnum].set_range(0,d[_MAXPWM])
  5036. self.widgets["mesa%d_numof_pwmgens"% boardnum].set_value(d[_MAXPWM])
  5037. if d[_MAXTPPWM]:
  5038. self.widgets["mesa%d_numof_tppwmgens"% boardnum].show()
  5039. self.widgets["mesa%d_numof_tpp_label"% boardnum].show()
  5040. self.widgets["mesa%d_3pwm_freq_label"% boardnum].show()
  5041. self.widgets["mesa%d_3pwm_freq_units"% boardnum].show()
  5042. self.widgets["mesa%d_3pwm_frequency"% boardnum].show()
  5043. else:
  5044. self.widgets["mesa%d_numof_tppwmgens"% boardnum].hide()
  5045. self.widgets["mesa%d_numof_tpp_label"% boardnum].hide()
  5046. self.widgets["mesa%d_3pwm_freq_label"% boardnum].hide()
  5047. self.widgets["mesa%d_3pwm_freq_units"% boardnum].hide()
  5048. self.widgets["mesa%d_3pwm_frequency"% boardnum].hide()
  5049. self.widgets["mesa%d_numof_tppwmgens"% boardnum].set_range(0,d[_MAXTPPWM])
  5050. self.widgets["mesa%d_numof_tppwmgens"% boardnum].set_value(d[_MAXTPPWM])
  5051. self.widgets["mesa%d_numof_stepgens"% boardnum].set_range(0,d[_MAXSTEP])
  5052. self.widgets["mesa%d_numof_stepgens"% boardnum].set_value(d[_MAXSTEP])
  5053. self.data["mesa%d_numof_resolvers"% boardnum] = (d[_MAXRES]) # TODO fix this hack should be selectable
  5054. if d[_MAXRES]:
  5055. self.widgets["mesa%d_numof_resolvers"% boardnum].show()
  5056. self.widgets["mesa%d_numof_resolvers"% boardnum].set_value(d[_MAXRES]*6)
  5057. self.widgets["mesa%d_numof_resolvers"% boardnum].set_sensitive(False)
  5058. self.widgets["mesa%d_numof_resolvers_label"% boardnum].show()
  5059. self.widgets["mesa%d_pwm_frequency"% boardnum].set_value(24000)
  5060. else:
  5061. self.widgets["mesa%d_numof_resolvers"% boardnum].hide()
  5062. self.widgets["mesa%d_numof_resolvers_label"% boardnum].hide()
  5063. self.widgets["mesa%d_numof_resolvers"% boardnum].set_value(0)
  5064. if d[_MAXSSERIALPORTS]:
  5065. self.widgets["mesa%d_numof_sserialports"% boardnum].show()
  5066. self.widgets["mesa%d_numof_sserialports_label"% boardnum].show()
  5067. self.widgets["mesa%d_numof_sserialchannels"% boardnum].show()
  5068. self.widgets["mesa%d_numof_sserialchannels_label"% boardnum].show()
  5069. else:
  5070. self.widgets["mesa%d_numof_sserialports"% boardnum].hide()
  5071. self.widgets["mesa%d_numof_sserialports_label"% boardnum].hide()
  5072. self.widgets["mesa%d_numof_sserialchannels"% boardnum].hide()
  5073. self.widgets["mesa%d_numof_sserialchannels_label"% boardnum].hide()
  5074. self.widgets["mesa%d_numof_sserialports"% boardnum].set_range(0,d[_MAXSSERIALPORTS])
  5075. self.widgets["mesa%d_numof_sserialports"% boardnum].set_value(d[_MAXSSERIALPORTS])
  5076. self.widgets["mesa%d_numof_sserialchannels"% boardnum].set_range(1,d[_MAXSSERIALCHANNELS])
  5077. self.widgets["mesa%d_numof_sserialchannels"% boardnum].set_value(d[_MAXSSERIALCHANNELS])
  5078. self.widgets["mesa%d_totalpins"% boardnum].set_text("%s"% d[_MAXGPIO])
  5079. self.widgets["mesa%d_3pwm_frequency"% boardnum].set_sensitive(d[_MAXTPPWM])
  5080. if d[_MAXRES]:
  5081. self.widgets["mesa%d_pwm_frequency"% boardnum].set_sensitive(False)
  5082. else:
  5083. self.widgets["mesa%d_pwm_frequency"% boardnum].set_sensitive(d[_MAXPWM])
  5084. self.widgets["mesa%d_pdm_frequency"% boardnum].set_sensitive(d[_MAXPWM])
  5085. if "7i43" in title:
  5086. self.widgets["mesa%d_parportaddrs"% boardnum].show()
  5087. self.widgets["mesa%d_parporttext"% boardnum].show()
  5088. else:
  5089. self.widgets["mesa%d_parportaddrs"% boardnum].hide()
  5090. self.widgets["mesa%d_parporttext"% boardnum].hide()
  5091. break
  5092. # This method converts data from the GUI page to signal names for pncconf's mesa data variables
  5093. # It starts by checking pin type to set up the proper lists to search
  5094. # then depending on the pin type widget data is converted to signal names.
  5095. # if the signal name is not in the list add it to Human_names, signal_names
  5096. # and disc-saved signalname lists
  5097. # if encoder, pwm, or stepper pins the related pin are also set properly
  5098. # it does this by searching the current firmware array and finding what the
  5099. # other related pins numbers are then changing them to the appropriate signalname.
  5100. def mesa_data_transfer(self,boardnum):
  5101. for concount,connector in enumerate(self.data["mesa%d_currentfirmwaredata"% boardnum][_NUMOFCNCTRS]) :
  5102. for pin in range(0,24):
  5103. p = 'mesa%dc%dpin%d' % (boardnum,connector,pin)
  5104. pinv = 'mesa%dc%dpin%dinv' % (boardnum,connector,pin)
  5105. ptype = 'mesa%dc%dpin%dtype' % (boardnum,connector,pin)
  5106. self.data_transfer(boardnum,connector,None,pin,p,pinv,ptype)
  5107. self.data["mesa%d_pwm_frequency"% boardnum] = self.widgets["mesa%d_pwm_frequency"% boardnum].get_value()
  5108. self.data["mesa%d_pdm_frequency"% boardnum] = self.widgets["mesa%d_pdm_frequency"% boardnum].get_value()
  5109. self.data["mesa%d_3pwm_frequency"% boardnum] = self.widgets["mesa%d_3pwm_frequency"% boardnum].get_value()
  5110. self.data["mesa%d_watchdog_timeout"% boardnum] = self.widgets["mesa%d_watchdog_timeout"% boardnum].get_value()
  5111. port = 0
  5112. for channel in range (0,self.data["mesa%d_currentfirmwaredata"% boardnum][_MAXSSERIALCHANNELS]):
  5113. if channel >4: break # TODO only have 5 channels worth of glade widgets
  5114. subboardname = self.data["mesa%dsserial%d_%dsubboard"% (boardnum, port, channel)]
  5115. #print "data transfer-channel ",channel," subboard name",subboardname
  5116. if subboardname == "none":
  5117. #print "no subboard for %s"% subboardname
  5118. continue
  5119. #print "sserial data transfering"
  5120. for pin in range (0,_SSCOMBOLEN):
  5121. p = 'mesa%dsserial%d_%dpin%d' % (boardnum, port, channel, pin)
  5122. pinv = 'mesa%dsserial%d_%dpin%dinv' % (boardnum, port, channel, pin)
  5123. ptype = 'mesa%dsserial%d_%dpin%dtype' % (boardnum, port, channel, pin)
  5124. self.data_transfer(boardnum,port,channel,pin,p,pinv,ptype)
  5125. #print "sserial data transfer",p
  5126. def data_transfer(self,boardnum,connector,channel,pin,p,pinv,ptype):
  5127. foundit = False
  5128. piter = self.widgets[p].get_active_iter()
  5129. ptiter = self.widgets[ptype].get_active_iter()
  5130. pintype = self.widgets[ptype].get_active_text()
  5131. selection = self.widgets[p].get_active_text()
  5132. #if "serial" in p:
  5133. # print "**** INFO mesa-data-transfer:",p," selection: ",selection," pintype: ",pintype
  5134. # print "**** INFO mesa-data-transfer:",ptiter,piter
  5135. # type NOTUSED
  5136. if pintype == NUSED:
  5137. self.data[p] = UNUSED_UNUSED
  5138. self.data[ptype] = NUSED
  5139. self.data[pinv] = False
  5140. return
  5141. # type GPIO input
  5142. if pintype == GPIOI:
  5143. signaltree = self.data._gpioisignaltree
  5144. ptypetree = self.data._gpioliststore
  5145. signaltocheck = hal_input_names
  5146. # type gpio output and open drain
  5147. elif pintype in (GPIOO,GPIOD):
  5148. signaltree = self.data._gpioosignaltree
  5149. ptypetree = self.data._gpioliststore
  5150. signaltocheck = hal_output_names
  5151. #type encoder
  5152. elif pintype in (ENCA,ENCB,ENCI,ENCM):
  5153. signaltree = self.data._encodersignaltree
  5154. ptypetree = self.data._encoderliststore
  5155. signaltocheck = hal_encoder_input_names
  5156. # resolvers
  5157. elif pintype in (RES0,RES1,RES2,RES3,RES4,RES5,RESU):
  5158. signaltree = self.data._resolversignaltree
  5159. ptypetree = self.data._resolverliststore
  5160. signaltocheck = hal_resolver_input_names
  5161. # 8i20 amplifier card
  5162. elif pintype == AMP8I20:
  5163. signaltree = self.data._8i20signaltree
  5164. ptypetree = self.data._8i20liststore
  5165. signaltocheck = hal_8i20_input_names
  5166. # potentiometer output
  5167. elif pintype in (POTO,POTE):
  5168. signaltree = self.data._potsignaltree
  5169. ptypetree = self.data._potliststore
  5170. signaltocheck = hal_pot_output_names
  5171. # analog in
  5172. elif pintype == (ANALOGIN):
  5173. signaltree = self.data._analoginsignaltree
  5174. ptypetree = self.data._analoginliststore
  5175. signaltocheck = hal_analog_input_names
  5176. #type mux encoder
  5177. elif pintype in (MXE0, MXE1, MXEI, MXEM, MXES):
  5178. signaltree = self.data._muxencodersignaltree
  5179. ptypetree = self.data._muxencoderliststore
  5180. signaltocheck = hal_encoder_input_names
  5181. # type PWM gen
  5182. elif pintype in( PDMP,PDMD,PDME):
  5183. signaltree = self.data._pwmsignaltree
  5184. if pintype == PDMP:
  5185. ptypetree = self.data._pdmcontrolliststore
  5186. else:
  5187. ptypetree = self.data._pdmrelatedliststore
  5188. signaltocheck = hal_pwm_output_names
  5189. # PDM
  5190. elif pintype in( PWMP,PWMD,PWME):
  5191. signaltree = self.data._pwmsignaltree
  5192. if pintype == PWMP:
  5193. ptypetree = self.data._pwmcontrolliststore
  5194. else:
  5195. ptypetree = self.data._pwmrelatedliststore
  5196. signaltocheck = hal_pwm_output_names
  5197. # Up/Down mode
  5198. elif pintype in( UDMU,UDMD,UDME):
  5199. signaltree = self.data._pwmsignaltree
  5200. if pintype == UDMU:
  5201. ptypetree = self.data._udmcontrolliststore
  5202. else:
  5203. ptypetree = self.data._udmrelatedliststore
  5204. signaltocheck = hal_pwm_output_names
  5205. # type tp pwm
  5206. elif pintype in (TPPWMA,TPPWMB,TPPWMC,TPPWMAN,TPPWMBN,TPPWMCN,TPPWME,TPPWMF):
  5207. signaltree = self.data._tppwmsignaltree
  5208. ptypetree = self.data._tppwmliststore
  5209. signaltocheck = hal_tppwm_output_names
  5210. # type step gen
  5211. elif pintype in (STEPA,STEPB):
  5212. signaltree = self.data._steppersignaltree
  5213. ptypetree = self.data._stepperliststore
  5214. signaltocheck = hal_stepper_names
  5215. # type sserial
  5216. elif pintype in (RXDATA0,TXDATA0,TXEN0,RXDATA1,TXDATA1,TXEN1,RXDATA2,TXDATA2,TXEN2,RXDATA3,TXDATA3,TXEN3,
  5217. RXDATA4,TXDATA4,TXEN4,RXDATA5,TXDATA5,TXEN5,RXDATA6,TXDATA6,TXEN6,RXDATA7,TXDATA7,TXEN7,
  5218. SS7I76M0,SS7I76M2,SS7I76M3,SS7I77M0,SS7I77M1,SS7I77M3,SS7I77M4):
  5219. signaltree = self.data._sserialsignaltree
  5220. ptypetree = self.data._sserialliststore
  5221. signaltocheck = hal_sserial_names
  5222. # this suppresses errors because of unused and unintialized sserial instances
  5223. elif pintype == None and "sserial" in ptype: return
  5224. else :
  5225. print "**** ERROR mesa-data-transfer: error unknown pin type:",pintype,"of ",ptype
  5226. return
  5227. # **Start widget to data Convertion**
  5228. # for encoder pins
  5229. if piter == None:
  5230. #print "callin pin changed !!!"
  5231. name ="mesa"
  5232. if "sserial" in p: name = "sserial"
  5233. self.on_general_pin_changed(None,name,boardnum,connector,channel,pin,True)
  5234. selection = self.widgets[p].get_active_text()
  5235. piter = self.widgets[p].get_active_iter()
  5236. if piter == None:
  5237. print "****ERROR PNCCONF: no custom name available"
  5238. return
  5239. #print "found signame -> ",selection," "
  5240. # ok we have a piter with a signal type now- lets convert it to a signalname
  5241. #if not "serial" in p:
  5242. # self.debug_iter(piter,p,"signal")
  5243. dummy, index = signaltree.get(piter,0,1)
  5244. #if not "serial" in p:
  5245. # print "signaltree: ",dummy
  5246. # self.debug_iter(ptiter,ptype,"ptype")
  5247. widgetptype, index2 = ptypetree.get(ptiter,0,1)
  5248. #if not "serial" in p:
  5249. # print "ptypetree: ",widgetptype
  5250. if pintype in (GPIOI,GPIOO,GPIOD,MXE0,MXE1,RES1,RES2,RES3,RES4,RES5,RESU,SS7I76M0,
  5251. SS7I76M2,SS7I76M3,SS7I77M0,SS7I77M1,SS7I77M3,SS7I77M4) or (index == 0):index2 = 0
  5252. elif pintype in ( TXDATA0,RXDATA0,TXEN0,TXDATA1,RXDATA1,TXEN1,TXDATA2,RXDATA2,TXEN2,TXDATA3,RXDATA3,TXEN3,TXDATA4,RXDATA4,TXEN4,
  5253. TXDATA5,RXDATA5,TXEN5,TXDATA6,RXDATA6,TXEN6,TXDATA7,RXDATA7,TXEN7 ):index2 = 0
  5254. #print index,index2,signaltocheck[index+index2]
  5255. self.data[p] = signaltocheck[index+index2]
  5256. self.data[ptype] = widgetptype
  5257. self.data[pinv] = self.widgets[pinv].get_active()
  5258. #if "serial" in p:
  5259. # print "*** INFO PNCCONF mesa pin:",p,"signalname:",self.data[p],"pin type:",widgetptype
  5260. # If we just reloaded a config then update the page right now
  5261. # as we already know what board /firmware /components are.
  5262. def on_mesa0_prepare(self, *args):
  5263. self.data.help = "help-mesa.txt"
  5264. boardnum = 0
  5265. if not self.widgets.createconfig.get_active() and not self.data._mesa0_configured :
  5266. self.set_mesa_options(boardnum,self.data.mesa0_boardtitle,self.data.mesa0_firmware,self.data.mesa0_numof_pwmgens,
  5267. self.data.mesa0_numof_tppwmgens,self.data.mesa0_numof_stepgens,self.data.mesa0_numof_encodergens,self.data.mesa0_numof_sserialports,
  5268. self.data.mesa0_numof_sserialchannels)
  5269. elif not self.data._mesa0_configured:
  5270. self.widgets.mesa0con2table.hide()
  5271. self.widgets.mesa0con3table.hide()
  5272. self.widgets.mesa0con4table.hide()
  5273. self.widgets.mesa0con5table.hide()
  5274. self.widgets.mesa0_parportaddrs.set_text(self.data.mesa0_parportaddrs)
  5275. for i in ("mesa0_sanity_7i29","mesa0_sanity_7i30","mesa0_sanity_7i33","mesa0_sanity_7i40","mesa0_sanity_7i48"):
  5276. self.widgets[i].set_active( self.data[i] )
  5277. def on_mesa0_next(self,*args):
  5278. model = self.widgets.mesa0_boardtitle.get_model()
  5279. active = self.widgets.mesa0_boardtitle.get_active()
  5280. if active < 0:
  5281. title = None
  5282. else: title = model[active][0]
  5283. if not self.data._mesa0_configured:
  5284. self.warning_dialog(_("You need to configure the mesa0 page.\n Choose the board type, firmware, component amounts and press 'Accept component changes' button'"),True)
  5285. self.widgets.druid1.set_page(self.widgets.mesa0)
  5286. return True
  5287. if not self.data.mesa0_currentfirmwaredata[_BOARDTITLE] == title:
  5288. self.warning_dialog(_("The chosen Mesa0 board is different from the current displayed.\nplease press 'Accept component changes' button'"),True)
  5289. self.widgets.druid1.set_page(self.widgets.mesa0)
  5290. return True
  5291. self.data.mesa0_parportaddrs = self.widgets.mesa0_parportaddrs.get_text()
  5292. self.mesa_data_transfer(0)
  5293. for i in ("mesa0_sanity_7i29","mesa0_sanity_7i30","mesa0_sanity_7i33","mesa0_sanity_7i40","mesa0_sanity_7i48"):
  5294. self.data[i] = self.widgets[i].get_active()
  5295. self.signal_sanity_check()
  5296. if self.data.number_mesa > 1:
  5297. self.widgets.druid1.set_page(self.widgets.mesa1)
  5298. return True
  5299. if self.data.number_pports<1:
  5300. self.widgets.druid1.set_page(self.widgets.xaxismotor)
  5301. return True
  5302. else:
  5303. self.widgets.druid1.set_page(self.widgets.pp1pport)
  5304. return True
  5305. # If we just reloaded a config then update the page right now
  5306. # as we already know what board /firmware /components are wanted.
  5307. def on_mesa1_prepare(self,*args):
  5308. self.data.help = "help-mesa.txt"
  5309. boardnum = 1
  5310. if not self.widgets.createconfig.get_active() and not self.data._mesa1_configured :
  5311. self.set_mesa_options(boardnum,self.data.mesa1_boardtitle,self.data.mesa1_firmware,self.data.mesa1_numof_pwmgens,
  5312. self.data.mesa1_numof_tppwmgens,self.data.mesa1_numof_stepgens,self.data.mesa1_numof_encodergens,self.data.mesa1_numof_sserialports,
  5313. self.data.mesa1_numof_sserialchannels)
  5314. elif not self.data._mesa1_configured:
  5315. self.widgets.mesa1con2table.hide()
  5316. self.widgets.mesa1con3table.hide()
  5317. self.widgets.mesa1con4table.hide()
  5318. self.widgets.mesa1con5table.hide()
  5319. self.widgets.mesa1_parportaddrs.set_text(self.data.mesa1_parportaddrs)
  5320. for i in ("mesa1_sanity_7i29","mesa1_sanity_7i30","mesa1_sanity_7i33","mesa1_sanity_7i40","mesa0_sanity_7i48"):
  5321. self.widgets[i].set_active( self.data[i] )
  5322. def on_mesa1_next(self,*args):
  5323. model = self.widgets.mesa1_boardtitle.get_model()
  5324. active = self.widgets.mesa1_boardtitle.get_active()
  5325. if active < 0:
  5326. title = None
  5327. else: title = model[active][0]
  5328. if not self.data._mesa1_configured:
  5329. self.warning_dialog(_("You need to configure the mesa1 page.\n Choose the board type, firmware, component amounts and press 'Accept component changes' button'"),True)
  5330. self.widgets.druid1.set_page(self.widgets.mesa1)
  5331. return True
  5332. if not self.data.mesa1_currentfirmwaredata[_BOARDTITLE] == title:
  5333. self.warning_dialog(_("The chosen Mesa1 board is different from the current displayed.\nplease press 'Accept component changes' button'"),True)
  5334. self.widgets.druid1.set_page(self.widgets.mesa1)
  5335. return True
  5336. self.data.mesa1_parportaddrs = self.widgets.mesa1_parportaddrs.get_text()
  5337. self.mesa_data_transfer(1)
  5338. for i in ("mesa1_sanity_7i29","mesa1_sanity_7i30","mesa1_sanity_7i33","mesa1_sanity_7i40","mesa0_sanity_7i48"):
  5339. self.data[i] = self.widgets[i].get_active()
  5340. self.signal_sanity_check()
  5341. if self.data.number_pports<1:
  5342. self.widgets.druid1.set_page(self.widgets.xaxismotor)
  5343. return True
  5344. def on_mesapanel_clicked(self, *args):
  5345. if not self.check_for_rt(): return
  5346. if not self.warning_dialog(_("Do to technical reasons this test panel can be loaded only once without reloading pncconf.\
  5347. You also will not be able to do any other testing untill you reload pncconf and quite possibly open a terminal and type 'halrun -U' \
  5348. I hesitate to even allow it's use but at times it's very useful.\nDo you wish to continue the test?"),False):
  5349. return
  5350. self.halrun = os.popen("halrun -I > /dev/null", "w")
  5351. self.halrun.write("loadrt threads period1=50000 name1=fast fp1=0 period2=1000000 name2=slow\n")
  5352. self.hal_cmnds("LOAD")
  5353. self.hal_cmnds("READ")
  5354. self.hal_cmnds("WRITE")
  5355. self.halrun.write("start\n")
  5356. self.halrun.write("loadusr halmeter\n")
  5357. self.halrun.flush()
  5358. time.sleep(1)
  5359. try:
  5360. PyApp(self,self.data,self.widgets)
  5361. except:
  5362. self.halrun.close()
  5363. a = os.popen("halrun -U > /dev/null", "w")
  5364. a.flush()
  5365. time.sleep(1)
  5366. a.close()
  5367. a.kill()
  5368. def on_mesapanel_returned(self, *args):
  5369. #print "Quit test panel"
  5370. try:
  5371. self.halrun.write("delsig all\n")
  5372. self.halrun.write("exit\n")
  5373. self.halrun.flush()
  5374. time.sleep(1)
  5375. self.halrun.close()
  5376. a = os.popen("halrun -U > /dev/null", "w")
  5377. a.flush()
  5378. time.sleep(1)
  5379. a.close()
  5380. a.kill()
  5381. except :
  5382. pass
  5383. def on_mesa_pintype_changed(self, widget,boardnum,connector,channel,pin):
  5384. #print "mesa pintype changed:",boardnum,connector,channel,pin
  5385. if not channel == None:
  5386. port = connector
  5387. p = 'mesa%dsserial%d_%dpin%d' % (boardnum, port, channel, pin)
  5388. ptype = 'mesa%dsserial%d_%dpin%dtype' % (boardnum, port, channel, pin)
  5389. blocksignal = "_mesa%dsignalhandlersserial%i_%ipin%i" % (boardnum, port, channel, pin)
  5390. ptypeblocksignal = "_mesa%dptypesignalhandlersserial%i_%ipin%i"% (boardnum, port, channel, pin)
  5391. else:
  5392. p = 'mesa%dc%dpin%d' % (boardnum,connector,pin)
  5393. ptype = 'mesa%dc%dpin%dtype' % (boardnum,connector,pin)
  5394. blocksignal = "_mesa%dsignalhandlerc%ipin%i"% (boardnum,connector,pin)
  5395. ptypeblocksignal = "_mesa%dptypesignalhandlerc%ipin%i" % (boardnum, connector,pin)
  5396. modelcheck = self.widgets[p].get_model()
  5397. modelptcheck = self.widgets[ptype].get_model()
  5398. new = self.widgets[ptype].get_active_text()
  5399. #print "pintypechanged",p
  5400. # switch GPIO input to GPIO output
  5401. # here we switch the available signal names in the combobox
  5402. # we block signals so pinchanged method is not called
  5403. if modelcheck == self.data._gpioisignaltree and new in (GPIOO,GPIOD):
  5404. #print "switch GPIO input ",p," to output",new
  5405. self.widgets[p].handler_block(self.data[blocksignal])
  5406. self.widgets[p].set_model(self.data._gpioosignaltree)
  5407. self.widgets[p].set_active(0)
  5408. self.widgets[p].handler_unblock(self.data[blocksignal])
  5409. # switch GPIO output to input
  5410. elif modelcheck == self.data._gpioosignaltree:
  5411. if new == GPIOI:
  5412. #print "switch GPIO output ",p,"to input"
  5413. self.widgets[p].handler_block(self.data[blocksignal])
  5414. self.widgets[p].set_model(self.data._gpioisignaltree)
  5415. self.widgets[p].set_active(0)
  5416. self.widgets[p].handler_unblock(self.data[blocksignal])
  5417. # switch between pulse width, pulse density or up/down mode analog modes
  5418. # here we search the firmware for related pins (eg PWMP,PWMD,PWME ) and change them too.
  5419. # we block signals so we don't call this routine again.
  5420. elif modelptcheck in (self.data._pwmcontrolliststore, self.data._pdmcontrolliststore, self.data._udmcontrolliststore):
  5421. relatedpins = [PWMP,PWMD,PWME]
  5422. if new == PWMP:
  5423. display = 0
  5424. relatedliststore = self.data._pwmrelatedliststore
  5425. controlliststore = self.data._pwmcontrolliststore
  5426. elif new == PDMP:
  5427. display = 1
  5428. relatedliststore = self.data._pdmrelatedliststore
  5429. controlliststore = self.data._pdmcontrolliststore
  5430. elif new == UDMU:
  5431. display = 2
  5432. relatedliststore = self.data._udmrelatedliststore
  5433. controlliststore = self.data._udmcontrolliststore
  5434. else:print "**** WARNING PNCCONF: pintype error-PWM type not found";return
  5435. self.widgets[ptype].handler_block(self.data[ptypeblocksignal])
  5436. self.widgets[ptype].set_model(controlliststore)
  5437. self.widgets[ptype].set_active(display)
  5438. self.widgets[ptype].handler_unblock(self.data[ptypeblocksignal])
  5439. pinlist = self.data.list_related_pins(relatedpins, boardnum, connector, channel, pin, 1)
  5440. for i in (pinlist):
  5441. relatedptype = i[0]
  5442. if relatedptype == ptype :continue
  5443. if not channel == None:
  5444. ptypeblocksignal = "_mesa%dptypesignalhandlersserial%i_%ipin%i"% (i[1], i[2],i[3],i[4])
  5445. else:
  5446. ptypeblocksignal = "_mesa%dptypesignalhandlerc%ipin%i" % (i[1], i[2],i[4])
  5447. self.widgets[relatedptype].handler_block(self.data[ptypeblocksignal])
  5448. j = self.widgets[relatedptype].get_active()
  5449. self.widgets[relatedptype].set_model(relatedliststore)
  5450. self.widgets[relatedptype].set_active(j)
  5451. self.widgets[relatedptype].handler_unblock(self.data[ptypeblocksignal])
  5452. else: print "**** WARNING PNCCONF: pintype error in pintypechanged method new ",new," pinnumber ",p
  5453. def on_mesa_component_value_changed(self, widget,boardnum):
  5454. self.in_mesa_prepare = True
  5455. self.data["mesa%d_pwm_frequency"% boardnum] = self.widgets["mesa%d_pwm_frequency"% boardnum].get_value()
  5456. self.data["mesa%d_pdm_frequency"% boardnum] = self.widgets["mesa%d_pdm_frequency"% boardnum].get_value()
  5457. self.data["mesa%d_watchdog_timeout"% boardnum] = self.widgets["mesa%d_watchdog_timeout"% boardnum].get_value()
  5458. numofpwmgens = self.data["mesa%d_numof_pwmgens"% boardnum] = int(self.widgets["mesa%d_numof_pwmgens"% boardnum].get_value())
  5459. numoftppwmgens = self.data["mesa%d_numof_tppwmgens"% boardnum] = int(self.widgets["mesa%d_numof_tppwmgens"% boardnum].get_value())
  5460. numofstepgens = self.data["mesa%d_numof_stepgens"% boardnum] = int(self.widgets["mesa%d_numof_stepgens"% boardnum].get_value())
  5461. numofencoders = self.data["mesa%d_numof_encodergens"% boardnum] = int(self.widgets["mesa%d_numof_encodergens"% boardnum].get_value())
  5462. numofsserialports = self.data["mesa%d_numof_sserialports"% boardnum] = int(self.widgets["mesa%d_numof_sserialports"% boardnum].get_value())
  5463. numofsserialchannels = self.data["mesa%d_numof_sserialchannels"% boardnum] = \
  5464. int(self.widgets["mesa%d_numof_sserialchannels"% boardnum].get_value())
  5465. title = self.data["mesa%d_boardtitle"% boardnum] = self.widgets["mesa%d_boardtitle"% boardnum].get_active_text()
  5466. firmware = self.data["mesa%d_firmware"% boardnum] = self.widgets["mesa%d_firmware"% boardnum].get_active_text()
  5467. self.set_mesa_options(boardnum,title,firmware,numofpwmgens,numoftppwmgens,numofstepgens,numofencoders,numofsserialports,numofsserialchannels)
  5468. return True
  5469. # This method sets up the mesa GUI page and is used when changing component values / firmware or boards from config page.
  5470. # it changes the component comboboxes according to the firmware max and user requested amounts
  5471. # it adds signal names to the signal name combo boxes according to component type and in the
  5472. # case of GPIO options selected on the basic page such as limit/homing types.
  5473. # it will grey out I/O tabs according to the selected board type.
  5474. # it uses GTK signal blocking to block on_general_pin_change and on_mesa_pintype_changed methods.
  5475. # Since this method is for intialization, there is no need to check for changes and this speeds up
  5476. # the update.
  5477. # 'mesafirmwaredata' holds all the firmware data.
  5478. # 'self.data.mesaX_currentfirmwaredata' hold the current selected firmware data (X is 0 or 1)
  5479. def set_mesa_options(self,boardnum,title,firmware,numofpwmgens,numoftppwmgens,numofstepgens,numofencoders,numofsserialports,numofsserialchannels):
  5480. self.widgets.druid1.set_buttons_sensitive(0,0,1,1)
  5481. self.pbar.set_text("Setting up Mesa tabs")
  5482. self.pbar.set_fraction(0)
  5483. self.window.show()
  5484. while gtk.events_pending():
  5485. gtk.main_iteration()
  5486. for search, item in enumerate(mesafirmwaredata):
  5487. d = mesafirmwaredata[search]
  5488. if not d[_BOARDTITLE] == title:continue
  5489. if d[_FIRMWARE] == firmware:
  5490. self.data["mesa%d_currentfirmwaredata"% boardnum] = mesafirmwaredata[search]
  5491. break
  5492. #print mesafirmwaredata[search]
  5493. self.widgets["mesa%dcon2table"% boardnum].hide()
  5494. self.widgets["mesa%dcon3table"% boardnum].hide()
  5495. self.widgets["mesa%dcon4table"% boardnum].hide()
  5496. self.widgets["mesa%dcon5table"% boardnum].hide()
  5497. self.widgets["mesa%dcon6table"% boardnum].hide()
  5498. self.widgets["mesa%dcon7table"% boardnum].hide()
  5499. self.widgets["mesa%dcon8table"% boardnum].hide()
  5500. self.widgets["mesa%dcon9table"% boardnum].hide()
  5501. self.widgets["mesa%dsserial0_0"% boardnum].hide()
  5502. self.widgets["mesa%dsserial0_1"% boardnum].hide()
  5503. self.widgets["mesa%dsserial0_2"% boardnum].hide()
  5504. self.widgets["mesa%dsserial0_3"% boardnum].hide()
  5505. self.widgets["mesa%dsserial0_4"% boardnum].hide()
  5506. currentboard = self.data["mesa%d_currentfirmwaredata"% boardnum][_BOARDNAME]
  5507. if currentboard == "5i20" or currentboard == "5i23":
  5508. self.widgets["mesa%dcon2table"% boardnum].show()
  5509. self.widgets["mesa%dcon3table"% boardnum].show()
  5510. self.widgets["mesa%dcon4table"% boardnum].show()
  5511. if currentboard == "5i22":
  5512. self.widgets["mesa%dcon2table"% boardnum].show()
  5513. self.widgets["mesa%dcon3table"% boardnum].show()
  5514. self.widgets["mesa%dcon4table"% boardnum].show()
  5515. self.widgets["mesa%dcon5table"% boardnum].show()
  5516. if currentboard == "5i25":
  5517. self.widgets["mesa%dcon2table"% boardnum].show()
  5518. self.widgets["mesa%dcon3table"% boardnum].show()
  5519. if currentboard == "7i43":
  5520. self.widgets["mesa%dcon3table"% boardnum].show()
  5521. self.widgets["mesa%dcon4table"% boardnum].show()
  5522. if currentboard == "3x20":
  5523. self.widgets["mesa%dcon4table"% boardnum].show()
  5524. self.widgets["mesa%dcon5table"% boardnum].show()
  5525. self.widgets["mesa%dcon6table"% boardnum].show()
  5526. self.widgets["mesa%dcon7table"% boardnum].show()
  5527. self.widgets["mesa%dcon8table"% boardnum].show()
  5528. self.widgets["mesa%dcon9table"% boardnum].show()
  5529. self.widgets["mesa%d"%boardnum].set_title("Mesa%d Configuration-Board: %s firmware: %s"% (boardnum,self.data["mesa%d_boardtitle"%boardnum],
  5530. self.data["mesa%d_currentfirmwaredata"% boardnum][_FIRMWARE]))
  5531. temp = "/usr/share/doc/hostmot2-firmware-%s/%s.PIN"% (self.data["mesa%d_currentfirmwaredata"% boardnum][_DIRECTORY],
  5532. self.data["mesa%d_currentfirmwaredata"% boardnum][_FIRMWARE] )
  5533. filename = os.path.expanduser(temp)
  5534. if os.path.exists(filename):
  5535. match = open(filename).read()
  5536. textbuffer = self.widgets.textoutput.get_buffer()
  5537. try :
  5538. textbuffer.set_text("%s\n\n"% filename)
  5539. textbuffer.insert_at_cursor(match)
  5540. except:
  5541. pass
  5542. for concount,connector in enumerate(self.data["mesa%d_currentfirmwaredata"% boardnum][_NUMOFCNCTRS]) :
  5543. for pin in range (0,24):
  5544. self.pbar.set_fraction((pin+1)/24.0)
  5545. while gtk.events_pending():
  5546. gtk.main_iteration()
  5547. firmptype,compnum = self.data["mesa%d_currentfirmwaredata"% boardnum][_STARTOFDATA+pin+(concount*24)]
  5548. p = 'mesa%dc%dpin%d' % (boardnum, connector, pin)
  5549. ptype = 'mesa%dc%dpin%dtype' % (boardnum, connector , pin)
  5550. #print "**** INFO set-mesa-options DATA:",self.data[p],p,self.data[ptype]
  5551. #print "**** INFO set-mesa-options FIRM:",firmptype
  5552. #print "**** INFO set-mesa-options WIDGET:",self.widgets[p].get_active_text(),self.widgets[ptype].get_active_text()
  5553. complabel = 'mesa%dc%dpin%dnum' % (boardnum, connector , pin)
  5554. pinv = 'mesa%dc%dpin%dinv' % (boardnum, connector , pin)
  5555. blocksignal = "_mesa%dsignalhandlerc%ipin%i" % (boardnum, connector, pin)
  5556. ptypeblocksignal = "_mesa%dptypesignalhandlerc%ipin%i" % (boardnum, connector,pin)
  5557. actblocksignal = "_mesa%dactivatehandlerc%ipin%i" % (boardnum, connector, pin)
  5558. # kill all widget signals:
  5559. self.widgets[ptype].handler_block(self.data[ptypeblocksignal])
  5560. self.widgets[p].handler_block(self.data[blocksignal])
  5561. self.widgets[p].child.handler_block(self.data[actblocksignal])
  5562. self.firmware_to_widgets(boardnum,firmptype,p,ptype,pinv,complabel,compnum,concount,pin,numofencoders,
  5563. numofpwmgens,numoftppwmgens,numofstepgens,None,numofsserialports,numofsserialchannels,False)
  5564. self.data["mesa%d_numof_stepgens"% boardnum] = numofstepgens
  5565. self.data["mesa%d_numof_pwmgens"% boardnum] = numofpwmgens
  5566. self.data["mesa%d_numof_encodergens"% boardnum] = numofencoders
  5567. self.data["mesa%d_numof_sserialports"% boardnum] = numofsserialports
  5568. self.data["mesa%d_numof_sserialchannels"% boardnum] = numofsserialchannels
  5569. self.widgets["mesa%d_numof_stepgens"% boardnum].set_value(numofstepgens)
  5570. self.widgets["mesa%d_numof_encodergens"% boardnum].set_value(numofencoders)
  5571. self.widgets["mesa%d_numof_pwmgens"% boardnum].set_value(numofpwmgens)
  5572. self.in_mesa_prepare = False
  5573. self.data["_mesa%d_configured"% boardnum] = True
  5574. # unblock all the widget signals again
  5575. for concount,connector in enumerate(self.data["mesa%d_currentfirmwaredata"% boardnum][_NUMOFCNCTRS]) :
  5576. for pin in range (0,24):
  5577. p = 'mesa%dc%dpin%d' % (boardnum, connector, pin)
  5578. ptype = 'mesa%dc%dpin%dtype' % (boardnum, connector , pin)
  5579. blocksignal = "_mesa%dsignalhandlerc%ipin%i" % (boardnum, connector, pin)
  5580. ptypeblocksignal = "_mesa%dptypesignalhandlerc%ipin%i" % (boardnum, connector,pin)
  5581. actblocksignal = "_mesa%dactivatehandlerc%ipin%i" % (boardnum, connector, pin)
  5582. self.widgets[ptype].handler_unblock(self.data[ptypeblocksignal])
  5583. self.widgets[p].handler_unblock(self.data[blocksignal])
  5584. self.widgets[p].child.handler_unblock(self.data[actblocksignal])
  5585. self.mesa_mainboard_data_to_widgets(boardnum)
  5586. self.window.hide()
  5587. self.widgets.druid1.set_buttons_sensitive(1,1,1,1)
  5588. def set_sserial_options(self,boardnum,port,channel):
  5589. numofsserialports = self.data["mesa%d_numof_sserialports"% boardnum]
  5590. numofsserialchannels = self.data["mesa%d_numof_sserialchannels"% boardnum]
  5591. subboardname = self.data["mesa%dsserial%d_%dsubboard"% (boardnum, port, channel)]
  5592. if subboardname == "none":return
  5593. self.widgets.druid1.set_buttons_sensitive(0,0,1,1)
  5594. self.pbar.set_text("Setting up Mesa Smart Serial tabs")
  5595. self.pbar.set_fraction(0)
  5596. self.window.show()
  5597. while gtk.events_pending():
  5598. gtk.main_iteration()
  5599. for subnum,temp in enumerate(mesadaughterdata):
  5600. #print mesadaughterdata[subnum][_SUBFIRMNAME],subboardname
  5601. if mesadaughterdata[subnum][_SUBFIRMNAME] == subboardname: break
  5602. #print "found subboard name:",mesadaughterdata[subnum][_SUBFIRMNAME],subboardname,subnum,"channel:",channel
  5603. for pin in range (0,_SSCOMBOLEN):
  5604. self.pbar.set_fraction((pin+1)/60.0)
  5605. while gtk.events_pending():
  5606. gtk.main_iteration()
  5607. p = 'mesa%dsserial%d_%dpin%d' % (boardnum, port, channel, pin)
  5608. ptype = 'mesa%dsserial%d_%dpin%dtype' % (boardnum, port, channel, pin)
  5609. pinv = 'mesa%dsserial%d_%dpin%dinv' % (boardnum, port, channel, pin)
  5610. complabel = 'mesa%dsserial%d_%dpin%dnum' % (boardnum, port, channel, pin)
  5611. blocksignal = "_mesa%dsignalhandlersserial%i_%ipin%i" % (boardnum, port, channel, pin)
  5612. ptypeblocksignal = "_mesa%dptypesignalhandlersserial%i_%ipin%i" % (boardnum, port, channel, pin)
  5613. actblocksignal = "_mesa%dactivatehandlersserial%i_%ipin%i" % (boardnum, port, channel, pin)
  5614. firmptype,compnum = mesadaughterdata[subnum][_SUBSTARTOFDATA+pin]
  5615. #print "sserial set options",p
  5616. # kill all widget signals:
  5617. self.widgets[ptype].handler_block(self.data[ptypeblocksignal])
  5618. self.widgets[p].handler_block(self.data[blocksignal])
  5619. self.widgets[p].child.handler_block(self.data[actblocksignal])
  5620. concount = 0
  5621. numofencoders = 10
  5622. numofpwmgens = 12
  5623. numoftppwmgens = 0
  5624. numofstepgens = 0
  5625. self.firmware_to_widgets(boardnum,firmptype,p,ptype,pinv,complabel,compnum,concount,pin,numofencoders,
  5626. numofpwmgens,numoftppwmgens,numofstepgens,subboardname,numofsserialports,numofsserialchannels,True)
  5627. # all this to unblock signals
  5628. for pin in range (0,_SSCOMBOLEN):
  5629. firmptype,compnum = mesadaughterdata[0][_SUBSTARTOFDATA+pin]
  5630. p = 'mesa%dsserial%d_%dpin%d' % (boardnum, port, channel, pin)
  5631. ptype = 'mesa%dsserial%d_%dpin%dtype' % (boardnum, port, channel, pin)
  5632. pinv = 'mesa%dsserial%d_%dpin%dinv' % (boardnum, port, channel, pin)
  5633. complabel = 'mesa%dsserial%d_%dpin%dnum' % (boardnum, port, channel, pin)
  5634. blocksignal = "_mesa%dsignalhandlersserial%i_%ipin%i" % (boardnum, port, channel, pin)
  5635. ptypeblocksignal = "_mesa%dptypesignalhandlersserial%i_%ipin%i" % (boardnum, port, channel, pin)
  5636. actblocksignal = "_mesa%dactivatehandlersserial%i_%ipin%i" % (boardnum, port, channel, pin)
  5637. # unblock all widget signals:
  5638. self.widgets[ptype].handler_unblock(self.data[ptypeblocksignal])
  5639. self.widgets[p].handler_unblock(self.data[blocksignal])
  5640. self.widgets[p].child.handler_unblock(self.data[actblocksignal])
  5641. # now that the widgets are set up as per firmware, change them as per the loaded data and add signals
  5642. for pin in range (0,_SSCOMBOLEN):
  5643. firmptype,compnum = mesadaughterdata[subnum][_SUBSTARTOFDATA+pin]
  5644. p = 'mesa%dsserial%d_%dpin%d' % (boardnum, port, channel, pin)
  5645. #print "INFO: data to widget smartserial- ",p, firmptype
  5646. ptype = 'mesa%dsserial%d_%dpin%dtype' % (boardnum, port, channel, pin)
  5647. pinv = 'mesa%dsserial%d_%dpin%dinv' % (boardnum, port, channel, pin)
  5648. self.data_to_widgets(boardnum,firmptype,compnum,p,ptype,pinv)
  5649. #print "sserial data-widget",p
  5650. self.widgets["mesa%d_numof_sserialports"% boardnum].set_value(numofsserialports)
  5651. self.widgets["mesa%d_numof_sserialchannels"% boardnum].set_value(numofsserialchannels)
  5652. self.window.hide()
  5653. self.widgets.druid1.set_buttons_sensitive(1,1,1,1)
  5654. def firmware_to_widgets(self,boardnum,firmptype,p,ptype,pinv,complabel,compnum,concount,pin,numofencoders,numofpwmgens,numoftppwmgens,
  5655. numofstepgens,subboardname,numofsserialports,numofsserialchannels,sserialflag):
  5656. currentboard = self.data["mesa%d_currentfirmwaredata"% boardnum][_BOARDNAME]
  5657. # *** convert widget[ptype] to component specified in firmwaredata ***
  5658. # if the board has less then 24 pins hide the extra comboboxes
  5659. if firmptype == NUSED:
  5660. self.widgets[p].hide()
  5661. self.widgets[ptype].hide()
  5662. self.widgets[pinv].hide()
  5663. self.widgets[complabel].hide()
  5664. self.widgets[ptype].set_model(self.data._notusedliststore)
  5665. self.widgets[ptype].set_active(0)
  5666. self.widgets[p].set_model(self.data._notusedsignaltree)
  5667. self.widgets[p].set_active(0)
  5668. return
  5669. else:
  5670. self.widgets[p].show()
  5671. self.widgets[ptype].show()
  5672. self.widgets[pinv].show()
  5673. self.widgets[complabel].show()
  5674. self.widgets[p].child.set_editable(True)
  5675. # ---SETUP GUI FOR ENCODER FAMILY COMPONENT---
  5676. # check that we are not converting more encoders that user requested
  5677. # if we are then we trick this routine into thinking the firware asked for GPIO:
  5678. # we can do that by changing the variable 'firmptype' to ask for GPIO
  5679. if firmptype in ( ENCA,ENCB,ENCI,ENCM ):
  5680. if numofencoders >= (compnum+1):
  5681. # if the combobox is not already displaying the right component:
  5682. # then we need to set up the comboboxes for this pin, otherwise skip it
  5683. if not self.widgets[ptype].get_active_text() == firmptype or not self.data["_mesa%d_configured"%boardnum]:
  5684. self.widgets[pinv].set_sensitive(0)
  5685. self.widgets[pinv].set_active(0)
  5686. self.widgets[ptype].set_model(self.data._encoderliststore)
  5687. self.widgets[p].set_model(self.data._encodersignaltree)
  5688. # we only add every 4th human name so the user can only select
  5689. # the encoder's 'A' signal name. If its the other signals
  5690. # we can add them all because pncconf controls what the user sees
  5691. if firmptype == ENCA:
  5692. self.widgets[complabel].set_text("%d:"%compnum)
  5693. self.widgets[p].set_active(0)
  5694. self.widgets[p].set_sensitive(1)
  5695. self.widgets[ptype].set_sensitive(0)
  5696. self.widgets[ptype].set_active(0)
  5697. # pncconf control what the user sees with these ones:
  5698. elif firmptype in(ENCB,ENCI,ENCM):
  5699. self.widgets[complabel].set_text("")
  5700. self.widgets[p].set_active(0)
  5701. self.widgets[p].set_sensitive(0)
  5702. self.widgets[ptype].set_sensitive(0)
  5703. for i,j in enumerate((ENCB,ENCI,ENCM)):
  5704. if firmptype == j:break
  5705. self.widgets[ptype].set_active(i+1)
  5706. else:
  5707. # user requested this encoder component to be GPIO instead
  5708. # We cheat a little and tell the rest of the method that the firmware says
  5709. # it should be GPIO and compnum is changed to signify that the GPIO can be changed
  5710. # from input to output
  5711. # Right now only mainboard GPIO can be changed
  5712. # sserial I/O can not
  5713. firmptype = GPIOI
  5714. compnum = 0
  5715. # --- mux encoder ---
  5716. elif firmptype in (MXE0,MXE1,MXEI,MXEM,MXES):
  5717. #print "**** INFO: MUX ENCODER:",firmptype,compnum,numofencoders
  5718. if numofencoders >= (compnum*2+1) or (firmptype == MXES and numofencoders >= compnum*2+1) or \
  5719. (firmptype == MXEM and numofencoders >= compnum +1):
  5720. # if the combobox is not already displaying the right component:
  5721. # then we need to set up the comboboxes for this pin, otherwise skip it
  5722. self.widgets[pinv].set_sensitive(0)
  5723. self.widgets[pinv].set_active(0)
  5724. pmodel = self.widgets[p].set_model(self.data._muxencodersignaltree)
  5725. ptmodel = self.widgets[ptype].set_model(self.data._muxencoderliststore)
  5726. self.widgets[ptype].set_active(pintype_muxencoder.index(firmptype))
  5727. self.widgets[ptype].set_sensitive(0)
  5728. self.widgets[p].set_active(0)
  5729. if firmptype in(MXE0,MXE1):
  5730. temp = 0
  5731. if firmptype == MXE1: temp = 1
  5732. self.widgets[complabel].set_text("%d:"%(compnum *2 + temp))
  5733. self.widgets[p].set_sensitive(1)
  5734. self.widgets[ptype].show()
  5735. self.widgets[p].show()
  5736. elif firmptype == MXEM:
  5737. self.widgets[complabel].set_text("%d:"%compnum)
  5738. self.widgets[p].set_sensitive(0)
  5739. self.widgets[ptype].show()
  5740. self.widgets[p].hide()
  5741. else:
  5742. self.widgets[complabel].set_text("")
  5743. self.widgets[p].set_sensitive(0)
  5744. self.widgets[ptype].hide()
  5745. self.widgets[p].hide()
  5746. else:
  5747. firmptype = GPIOI
  5748. compnum = 0
  5749. # ---SETUP GUI FOR RESOLVER FAMILY COMPONENTS---
  5750. elif firmptype in (RES0,RES1,RES2,RES3,RES4,RES5,RESU):
  5751. if 0 == 0:
  5752. self.widgets[pinv].set_sensitive(0)
  5753. self.widgets[pinv].set_active(0)
  5754. self.widgets[p].set_model(self.data._resolversignaltree)
  5755. self.widgets[ptype].set_model(self.data._resolverliststore)
  5756. self.widgets[ptype].set_sensitive(0)
  5757. self.widgets[ptype].set_active(0)
  5758. if firmptype == RESU:
  5759. self.widgets[complabel].set_text("")
  5760. self.widgets[p].hide()
  5761. self.widgets[p].set_sensitive(0)
  5762. self.widgets[p].set_active(0)
  5763. self.widgets[ptype].set_active(6)
  5764. else:
  5765. temp = (RES0,RES1,RES2,RES3,RES4,RES5)
  5766. self.widgets[p].show()
  5767. for num,i in enumerate(temp):
  5768. if firmptype == i:break
  5769. self.widgets[complabel].set_text("%d:"% (compnum*6+num))
  5770. self.widgets[p].set_sensitive(1)
  5771. self.widgets[p].set_active(0)
  5772. self.widgets[ptype].set_active(num)
  5773. # ---SETUP 8i20 amp---
  5774. elif firmptype == AMP8I20:
  5775. self.widgets[ptype].set_model(self.data._8i20liststore)
  5776. self.widgets[p].set_model(self.data._8i20signaltree)
  5777. self.widgets[complabel].set_text("%d:"%compnum)
  5778. self.widgets[p].set_active(0)
  5779. self.widgets[p].set_sensitive(1)
  5780. self.widgets[pinv].set_sensitive(1)
  5781. self.widgets[pinv].set_active(0)
  5782. self.widgets[ptype].set_sensitive(0)
  5783. self.widgets[ptype].set_active(0)
  5784. # --- SETUP potentiometer output
  5785. elif firmptype in (POTO,POTE):
  5786. self.widgets[ptype].set_model(self.data._potliststore)
  5787. self.widgets[p].set_model(self.data._potsignaltree)
  5788. self.widgets[complabel].set_text("%d:"%compnum)
  5789. self.widgets[p].set_active(0)
  5790. self.widgets[pinv].set_sensitive(1)
  5791. self.widgets[pinv].set_active(0)
  5792. self.widgets[ptype].set_sensitive(0)
  5793. if firmptype == POTO:
  5794. self.widgets[ptype].set_active(0)
  5795. self.widgets[p].set_sensitive(1)
  5796. else:
  5797. self.widgets[ptype].set_active(1)
  5798. self.widgets[p].set_sensitive(0)
  5799. # --- SETUP analog input
  5800. elif firmptype == (ANALOGIN):
  5801. self.widgets[ptype].set_model(self.data._analoginliststore)
  5802. self.widgets[p].set_model(self.data._analoginsignaltree)
  5803. self.widgets[complabel].set_text("%d:"%compnum)
  5804. self.widgets[p].set_active(0)
  5805. self.widgets[pinv].set_sensitive(1)
  5806. self.widgets[pinv].set_active(0)
  5807. self.widgets[ptype].set_sensitive(0)
  5808. self.widgets[ptype].set_active(0)
  5809. self.widgets[p].set_sensitive(1)
  5810. # ---SETUP GUI FOR PWM FAMILY COMPONENT---
  5811. # the user has a choice of pulse width or pulse density modulation
  5812. elif firmptype in ( PWMP,PWMD,PWME,PDMP,PDMD,PDME ):
  5813. if numofpwmgens >= (compnum+1):
  5814. self.widgets[pinv].set_sensitive(1)
  5815. self.widgets[pinv].set_active(0)
  5816. self.widgets[p].set_model(self.data._pwmsignaltree)
  5817. # only add the -pulse signal names for the user to see
  5818. if firmptype in(PWMP,PDMP):
  5819. self.widgets[complabel].set_text("%d:"%compnum)
  5820. #print "firmptype = controlling"
  5821. self.widgets[ptype].set_model(self.data._pwmcontrolliststore)
  5822. self.widgets[ptype].set_sensitive(not sserialflag) # sserial pwm cannot be changed
  5823. self.widgets[p].set_sensitive(1)
  5824. self.widgets[p].set_active(0)
  5825. self.widgets[ptype].set_active(0)
  5826. # add them all here
  5827. elif firmptype in (PWMD,PWME,PDMD,PDME):
  5828. self.widgets[complabel].set_text("")
  5829. #print "firmptype = related"
  5830. if firmptype in (PWMD,PWME):
  5831. self.widgets[ptype].set_model(self.data._pwmrelatedliststore)
  5832. else:
  5833. self.widgets[ptype].set_model(self.data._pdmrelatedliststore)
  5834. self.widgets[p].set_sensitive(0)
  5835. self.widgets[p].set_active(0)
  5836. self.widgets[ptype].set_sensitive(0)
  5837. temp = 1
  5838. if firmptype in (PWME,PDME):
  5839. self.widgets[pinv].set_sensitive(0)
  5840. temp = 2
  5841. self.widgets[ptype].set_active(temp)
  5842. else:
  5843. firmptype = GPIOI
  5844. compnum = 0
  5845. # ---SETUP GUI FOR TP PWM FAMILY COMPONENT---
  5846. elif firmptype in ( TPPWMA,TPPWMB,TPPWMC,TPPWMAN,TPPWMBN,TPPWMCN,TPPWME,TPPWMF ):
  5847. if numoftppwmgens >= (compnum+1):
  5848. if not self.widgets[ptype].get_active_text() == firmptype or not self.data["_mesa%d_configured"%boardnum]:
  5849. self.widgets[p].set_model(self.data._tppwmsignaltree)
  5850. self.widgets[ptype].set_model(self.data._tppwmliststore)
  5851. self.widgets[pinv].set_sensitive(0)
  5852. self.widgets[pinv].set_active(0)
  5853. self.widgets[ptype].set_sensitive(0)
  5854. self.widgets[ptype].set_active(pintype_tp_pwm.index(firmptype))
  5855. self.widgets[p].set_active(0)
  5856. # only add the -a signal names for the user to change
  5857. if firmptype == TPPWMA:
  5858. self.widgets[complabel].set_text("%d:"%compnum)
  5859. self.widgets[p].set_sensitive(1)
  5860. # the rest the user can't change
  5861. else:
  5862. self.widgets[complabel].set_text("")
  5863. self.widgets[p].set_sensitive(0)
  5864. else:
  5865. firmptype = GPIOI
  5866. compnum = 0
  5867. # ---SETUP SMART SERIAL COMPONENTS---
  5868. # smart serial has port numbers (0-3) and channels (0-7).
  5869. # so the component number check is different from other components it checks the port number and channel number
  5870. elif firmptype in (TXDATA0,RXDATA0,TXEN0,TXDATA1,RXDATA1,TXEN1,TXDATA2,RXDATA2,TXEN2,TXDATA3,RXDATA3,TXEN3,
  5871. TXDATA4,RXDATA4,TXEN4,TXDATA5,RXDATA5,TXEN5,TXDATA6,RXDATA6,TXEN6,TXDATA7,RXDATA7,TXEN7,
  5872. SS7I76M0,SS7I76M2,SS7I76M3,SS7I77M0,SS7I77M1,SS7I77M3,SS7I77M4):
  5873. channelnum = 1
  5874. if firmptype in (TXDATA1,RXDATA1,TXEN1,SS7I77M1): channelnum = 2
  5875. if firmptype in (TXDATA2,RXDATA2,TXEN2,SS7I76M2): channelnum = 3
  5876. if firmptype in (TXDATA3,RXDATA3,TXEN3,SS7I76M3,SS7I77M3): channelnum = 4
  5877. if firmptype in (TXDATA4,RXDATA4,TXEN4,SS7I77M4): channelnum = 5
  5878. if firmptype in (TXDATA5,RXDATA5,TXEN5): channelnum = 6
  5879. if firmptype in (TXDATA6,RXDATA6,TXEN6): channelnum = 7
  5880. if firmptype in (TXDATA7,RXDATA7,TXEN7): channelnum = 8
  5881. #print "**** INFO: SMART SERIAL ENCODER:",firmptype," compnum = ",compnum
  5882. #print "sserial channel:%d"% numofsserialchannels
  5883. if numofsserialports >= (compnum + 1) and numofsserialchannels >= (channelnum):
  5884. # if the combobox is not already displaying the right component:
  5885. # then we need to set up the comboboxes for this pin, otherwise skip it
  5886. #if compnum < 5: # TODO hack - haven't made all the serial components in glade yet
  5887. # self.widgets["mesa%dsserialtab%d"% (boardnum,compnum)].show()
  5888. self.widgets[pinv].set_sensitive(0)
  5889. self.widgets[pinv].set_active(0)
  5890. pmodel = self.widgets[p].set_model(self.data._sserialsignaltree)
  5891. ptmodel = self.widgets[ptype].set_model(self.data._sserialliststore)
  5892. self.widgets[ptype].set_active(pintype_sserial.index(firmptype))
  5893. self.widgets[ptype].set_sensitive(0)
  5894. self.widgets[p].set_active(0)
  5895. self.widgets[p].child.set_editable(False) # sserial cannot have custom names
  5896. if firmptype in (TXDATA0,TXDATA1,TXDATA2,TXDATA3,TXDATA4,SS7I76M0,SS7I76M2,SS7I76M3,SS7I77M0,SS7I77M1,SS7I77M3,SS7I77M4):
  5897. self.widgets[complabel].set_text("%d:"% (channelnum -1))
  5898. if channelnum < 6:#TODO fix hack hardcoded at 5 sserial channels
  5899. self.widgets[p].set_sensitive(1)
  5900. else:
  5901. self.widgets[p].set_sensitive(0)
  5902. # if the sserial ptype is 7i76 or 7i77 then the data must be set to 7i76/7i77 signal
  5903. # as that sserial instance can only be for the 7i76/7i77 I/O points
  5904. if firmptype in (SS7I76M0,SS7I76M2,SS7I76M3):
  5905. self.data[p] = I7I76_M0_T
  5906. self.data[ptype] = firmptype
  5907. self.widgets[p].set_sensitive(0)
  5908. elif firmptype in (SS7I77M0,SS7I77M1,SS7I77M3,SS7I77M4):
  5909. self.data[p] = I7I77_M0_T
  5910. self.data[ptype] = firmptype
  5911. self.widgets[p].set_sensitive(0)
  5912. else:
  5913. self.widgets[complabel].set_text("")
  5914. self.widgets[p].set_sensitive(0)
  5915. else:
  5916. firmptype = GPIOI
  5917. compnum = 0
  5918. # ---SETUP FOR STEPPER FAMILY COMPONENT---
  5919. elif firmptype in (STEPA,STEPB):
  5920. if numofstepgens >= (compnum+1):
  5921. self.widgets[ptype].set_model(self.data._stepperliststore)
  5922. self.widgets[p].set_model(self.data._steppersignaltree)
  5923. self.widgets[pinv].set_sensitive(1)
  5924. self.widgets[pinv].set_active(0)
  5925. self.widgets[ptype].set_sensitive(0)
  5926. self.widgets[ptype].set_active( pintype_stepper.index(firmptype) )
  5927. self.widgets[p].set_active(0)
  5928. #self.widgets[p].set_active(0)
  5929. if firmptype == STEPA:
  5930. self.widgets[complabel].set_text("%d:"%compnum)
  5931. self.widgets[p].set_sensitive(1)
  5932. elif firmptype == STEPB:
  5933. self.widgets[complabel].set_text("")
  5934. self.widgets[p].set_sensitive(0)
  5935. else:
  5936. firmptype = GPIOI
  5937. compnum = 0
  5938. # ---SETUP FOR GPIO FAMILY COMPONENT---
  5939. # first check to see if firmware says it should be in GPIO family
  5940. # (note this can be because firmware says it should be some other
  5941. # type but the user wants to deselect it so as to use it as GPIO
  5942. # this is done in the firmptype checks before this check.
  5943. # They will change firmptype variable to GPIOI)
  5944. # check if firmptype is in GPIO family
  5945. # check if widget is already configured
  5946. # we now set everything in a known state.
  5947. if firmptype in (GPIOI,GPIOO,GPIOD):
  5948. widgettext = self.widgets[ptype].get_active_text()
  5949. if sserialflag:
  5950. if "7i77" in subboardname or "7i76" in subboardname:
  5951. if pin <16:
  5952. self.widgets[complabel].set_text("%02d:"%(pin)) # sserial input
  5953. elif (pin >23 and pin < 40):
  5954. self.widgets[complabel].set_text("%02d:"%(pin-8)) # sserial input
  5955. elif pin >15 and pin < 24:
  5956. self.widgets[complabel].set_text("%02d:"%(pin-16)) #sserial output
  5957. elif pin >39:
  5958. self.widgets[complabel].set_text("%02d:"%(pin-32)) #sserial output
  5959. elif "7i70" in subboardname or "7i71" in subboardname:
  5960. self.widgets[complabel].set_text("%02d:"%(pin))
  5961. else:
  5962. if pin <24 :
  5963. self.widgets[complabel].set_text("%02d:"%(concount*24+pin)) # sserial input
  5964. else:
  5965. self.widgets[complabel].set_text("%02d:"%(concount*24+pin-24)) #sserial output
  5966. elif '5i25' in currentboard:
  5967. self.widgets[complabel].set_text("%03d:"%(concount*16+pin))# 5i25 mainboard GPIO
  5968. else:
  5969. self.widgets[complabel].set_text("%03d:"%(concount*24+pin))# mainboard GPIO
  5970. if compnum == 100 and widgettext == firmptype:
  5971. return
  5972. elif not compnum == 100 and (widgettext in (GPIOI,GPIOO,GPIOD)):
  5973. return
  5974. else:
  5975. #self.widgets[ptype].show()
  5976. #self.widgets[p].show()
  5977. self.widgets[p].set_sensitive(1)
  5978. self.widgets[pinv].set_sensitive(1)
  5979. self.widgets[ptype].set_sensitive(not compnum == 100) # compnum = 100 means GPIO cannot be changed by user
  5980. self.widgets[ptype].set_model(self.data._gpioliststore)
  5981. if firmptype == GPIOI:
  5982. # set pin treestore to gpioi signals
  5983. if not self.widgets[p].get_model() == self.data._gpioisignaltree:
  5984. self.widgets[p].set_model(self.data._gpioisignaltree)
  5985. # set ptype gpioi
  5986. self.widgets[ptype].set_active(0)
  5987. # set p unused signal
  5988. self.widgets[p].set_active(0)
  5989. # set pinv unset
  5990. self.widgets[pinv].set_active(False)
  5991. else:
  5992. if not self.widgets[p].get_model() == self.data._gpioosignaltree:
  5993. self.widgets[p].set_model(self.data._gpioosignaltree)
  5994. # set ptype gpioo
  5995. self.widgets[ptype].set_active(1)
  5996. # set p unused signal
  5997. self.widgets[p].set_active(0)
  5998. # set pinv unset
  5999. self.widgets[pinv].set_active(False)
  6000. def mesa_mainboard_data_to_widgets(self,boardnum):
  6001. for concount,connector in enumerate(self.data["mesa%d_currentfirmwaredata"% boardnum][_NUMOFCNCTRS]) :
  6002. for pin in range (0,24):
  6003. firmptype,compnum = self.data["mesa%d_currentfirmwaredata"% boardnum][_STARTOFDATA+pin+(concount*24)]
  6004. p = 'mesa%dc%dpin%d' % (boardnum, connector, pin)
  6005. ptype = 'mesa%dc%dpin%dtype' % (boardnum, connector , pin)
  6006. pinv = 'mesa%dc%dpin%dinv' % (boardnum, connector , pin)
  6007. self.data_to_widgets(boardnum,firmptype,compnum,p,ptype,pinv)
  6008. # by now the widgets should be right according to the firmware (and user deselected components)
  6009. # now we apply the data - setting signalnames and possible changing the pintype choice (eg pwm to pdm)
  6010. # We need to only set the 'controlling' signalname the pinchanged method will be called
  6011. # immediately and set the 'related' pins (if there are related pins)
  6012. def data_to_widgets(self,boardnum,firmptype,compnum,p,ptype,pinv):
  6013. debug = False
  6014. datap = self.data[p]
  6015. dataptype = self.data[ptype]
  6016. datapinv = self.data[pinv]
  6017. widgetp = self.widgets[p].get_active_text()
  6018. widgetptype = self.widgets[ptype].get_active_text()
  6019. #print "**** INFO set-data-options DATA:",p,datap,dataptype
  6020. #print "**** INFO set-data-options WIDGET:",p,widgetp,widgetptype
  6021. # ignore related pins
  6022. if widgetptype in (ENCB,ENCI,ENCM,
  6023. MXEI,MXEM,MXES,
  6024. RESU,
  6025. STEPB,STEPC,STEPD,STEPE,STEPF,
  6026. PDMD,PDME,PWMD,PWME,UDMD,UDME,
  6027. TPPWMB,TPPWMC,TPPWMAN,TPPWMBN,TPPWMCN,TPPWME,TPPWMF,
  6028. NUSED,POTD,POTE,
  6029. RXDATA0,TXEN0,RXDATA1,TXEN1,RXDATA2,TXEN2,RXDATA3,TXEN3,
  6030. RXDATA4,TXEN4,RXDATA5,TXEN5,RXDATA6,TXEN6,RXDATA7,TXEN7
  6031. ):
  6032. self.widgets[pinv].set_active(datapinv)
  6033. return
  6034. # type GPIO
  6035. # if compnum = 100 then it means that the GPIO type can not
  6036. # be changed from what the firmware designates it as.
  6037. if widgetptype in (GPIOI,GPIOO,GPIOD):
  6038. #print "data ptype index:",pintype_gpio.index(dataptype)
  6039. #self.debug_iter(0,p,"data to widget")
  6040. #self.debug_iter(0,ptype,"data to widget")
  6041. # signal names for GPIO INPUT
  6042. #print "compnum = ",compnum
  6043. if compnum == 100: dataptype = widgetptype
  6044. self.widgets[pinv].set_active(self.data[pinv])
  6045. try:
  6046. self.widgets[ptype].set_active( pintype_gpio.index(dataptype) )
  6047. except:
  6048. self.widgets[ptype].set_active( pintype_gpio.index(widgetptype) )
  6049. # if GPIOI or dataptype not in GPIO family force it GPIOI
  6050. if dataptype == GPIOI or dataptype not in(GPIOO,GPIOI,GPIOD):
  6051. human = human_input_names
  6052. signal = hal_input_names
  6053. tree = self.data._gpioisignaltree
  6054. # signal names for GPIO OUTPUT and OPEN DRAIN OUTPUT
  6055. elif dataptype in (GPIOO,GPIOD):
  6056. human = human_output_names
  6057. signal = hal_output_names
  6058. tree = self.data._gpioosignaltree
  6059. self.widgets[p].set_model(tree)
  6060. try:
  6061. signalindex = signal.index(datap)
  6062. except:
  6063. if debug: print "**** INFO: PNCCONF warning no GPIO signal named: %s\n found for pin %s"% (datap , p)
  6064. signalindex = 0
  6065. #print "gpio temp ptype:",dataptype,datap,signalindex
  6066. count = 0
  6067. temp = (0) # set unused gpio if no match
  6068. if signalindex > 0:
  6069. for row,parent in enumerate(human):
  6070. if len(parent[1]) == 0:continue
  6071. for column,child in enumerate(parent[1]):
  6072. count +=1
  6073. #print row,column,count,parent[0],child
  6074. if count == signalindex:
  6075. #print "match",row,column
  6076. break
  6077. if count >= signalindex:break
  6078. temp = (row,column)
  6079. treeiter = tree.get_iter(temp)
  6080. self.widgets[p].set_active_iter(treeiter)
  6081. # type encoder / mux encoder
  6082. elif widgetptype == ENCA or widgetptype in(MXE0,MXE1):
  6083. try:
  6084. signalindex = hal_encoder_input_names.index(datap)
  6085. except:
  6086. if debug: print "**** INFO: PNCCONF warning no ENCODER signal named: %s\n found for pin %s"% (datap ,p)
  6087. signalindex = 0
  6088. #print "ENC ->dataptype:",self.data[ptype]," dataptype:",self.data[p],signalindex
  6089. count = -3
  6090. if signalindex > 0:
  6091. for row,parent in enumerate(human_encoder_input_names):
  6092. if len(parent[1]) == 0:continue
  6093. for column,child in enumerate(parent[1]):
  6094. count +=4
  6095. #print row,column,count,parent[0],child
  6096. if count == signalindex:
  6097. #print "match",row,column
  6098. break
  6099. if count >= signalindex:break
  6100. temp = (row,column)
  6101. else:
  6102. temp = (0) # set unused encoder if no match
  6103. #print temp
  6104. if widgetptype == ENCA:
  6105. treeiter = self.data._encodersignaltree.get_iter(temp)
  6106. else:
  6107. treeiter = self.data._muxencodersignaltree.get_iter(temp)
  6108. self.widgets[p].set_active_iter(treeiter)
  6109. # type resolver
  6110. elif widgetptype in(RES0,RES1,RES2,RES3,RES4,RES5,RESU):
  6111. try:
  6112. signalindex = hal_resolver_input_names.index(datap)
  6113. except:
  6114. if debug: print "**** INFO: PNCCONF warning no resolver signal named: %s\n found for pin %s"% (datap ,p)
  6115. signalindex = 0
  6116. #print "dataptype:",self.data[ptype]," dataptype:",self.data[p],signalindex
  6117. count = 0
  6118. if signalindex > 0:
  6119. for row,parent in enumerate(human_resolver_input_names):
  6120. if row == 0: continue
  6121. if len(parent[1]) == 0:
  6122. count +=1
  6123. #print row,count,"parent-",parent[0]
  6124. if count == signalindex:
  6125. #print "match",row
  6126. temp = (row)
  6127. break
  6128. continue
  6129. for column,child in enumerate(parent[1]):
  6130. count +=1
  6131. #print row,column,count,parent[0],child
  6132. if count == signalindex:
  6133. #print "match",row
  6134. temp = (row,column)
  6135. break
  6136. if count >= signalindex:break
  6137. else:
  6138. temp = (0) # set unused resolver
  6139. #print "temp",temp
  6140. treeiter = self.data._resolversignaltree.get_iter(temp)
  6141. self.widgets[p].set_active_iter(treeiter)
  6142. # Type 8i20 AMP
  6143. elif widgetptype == AMP8I20:
  6144. try:
  6145. signalindex = hal_8i20_input_names.index(datap)
  6146. except:
  6147. if debug: print "**** INFO: PNCCONF warning no 8i20 signal named: %s\n found for pin %s"% (datap ,p)
  6148. signalindex = 0
  6149. #print "dataptype:",self.data[ptype]," dataptype:",self.data[p],signalindex
  6150. count = 0
  6151. if signalindex > 0:
  6152. for row,parent in enumerate(human_8i20_input_names):
  6153. if row == 0: continue
  6154. if len(parent[1]) == 0:
  6155. count +=1
  6156. #print row,count,"parent-",parent[0]
  6157. if count == signalindex:
  6158. #print "match",row
  6159. temp = (row)
  6160. break
  6161. continue
  6162. for column,child in enumerate(parent[1]):
  6163. count +=1
  6164. #print row,column,count,parent[0],child
  6165. if count == signalindex:
  6166. #print "match",row
  6167. temp = (row,column)
  6168. break
  6169. if count >= signalindex:break
  6170. else:
  6171. temp = (0) # set unused 8i20 amp
  6172. #print "temp",temp
  6173. treeiter = self.data._8i20signaltree.get_iter(temp)
  6174. self.widgets[p].set_active_iter(treeiter)
  6175. # Type potentiometer (7i76"s spindle control)
  6176. elif widgetptype in (POTO,POTE):
  6177. self.widgets[pinv].set_active(self.data[pinv])
  6178. try:
  6179. signalindex = hal_pot_output_names.index(datap)
  6180. except:
  6181. if debug: print "**** INFO: PNCCONF warning no potentiometer signal named: %s\n found for pin %s"% (datap ,p)
  6182. signalindex = 0
  6183. #print "dataptype:",self.data[ptype]," dataptype:",self.data[p],signalindex
  6184. count = -1
  6185. if signalindex > 0:
  6186. for row,parent in enumerate(human_pot_output_names):
  6187. if row == 0: continue
  6188. if len(parent[1]) == 0:
  6189. count +=2
  6190. #print row,count,"parent-",parent[0]
  6191. if count == signalindex:
  6192. #print "match",row
  6193. temp = (row)
  6194. break
  6195. continue
  6196. for column,child in enumerate(parent[1]):
  6197. count +=2
  6198. #print row,column,count,parent[0],child
  6199. if count == signalindex:
  6200. #print "match",row
  6201. temp = (row,column)
  6202. break
  6203. if count >= signalindex:break
  6204. else:
  6205. temp = (0) # set unused potentiometer
  6206. #print "temp",temp
  6207. treeiter = self.data._potsignaltree.get_iter(temp)
  6208. self.widgets[p].set_active_iter(treeiter)
  6209. # Type analog in
  6210. elif widgetptype == ANALOGIN:
  6211. try:
  6212. signalindex = hal_analog_input_names.index(datap)
  6213. except:
  6214. if debug: print "**** INFO: PNCCONF warning no analog in signal named: %s\n found for pin %s"% (datap ,p)
  6215. signalindex = 0
  6216. #print "dataptype:",self.data[ptype]," dataptype:",self.data[p],signalindex
  6217. count = 0
  6218. if signalindex > 0:
  6219. for row,parent in enumerate(human_analog_input_names):
  6220. if row == 0: continue
  6221. if len(parent[1]) == 0:
  6222. count +=1
  6223. #print row,count,"parent-",parent[0]
  6224. if count == signalindex:
  6225. #print "match",row
  6226. temp = (row)
  6227. break
  6228. continue
  6229. for column,child in enumerate(parent[1]):
  6230. count +=1
  6231. #print row,column,count,parent[0],child
  6232. if count == signalindex:
  6233. #print "match",row
  6234. temp = (row,column)
  6235. break
  6236. if count >= signalindex:break
  6237. else:
  6238. temp = (0) # set unused 8i20 amp
  6239. #print "temp",temp
  6240. treeiter = self.data._analoginsignaltree.get_iter(temp)
  6241. self.widgets[p].set_active_iter(treeiter)
  6242. # type PWM gen
  6243. elif widgetptype in (PDMP,PWMP,UDMU):
  6244. self.widgets[pinv].set_active(datapinv)
  6245. if self.widgets["mesa%d_numof_resolvers"% boardnum].get_value(): dataptype = UDMU # hack resolver board needs UDMU
  6246. if dataptype == PDMP:
  6247. #print "pdm"
  6248. self.widgets[ptype].set_model(self.data._pdmcontrolliststore)
  6249. self.widgets[ptype].set_active(1)
  6250. elif dataptype == PWMP:
  6251. #print "pwm",self.data._pwmcontrolliststore
  6252. self.widgets[ptype].set_model(self.data._pwmcontrolliststore)
  6253. self.widgets[ptype].set_active(0)
  6254. elif dataptype == UDMU:
  6255. #print "udm",self.data._udmcontrolliststore
  6256. self.widgets[ptype].set_model(self.data._udmcontrolliststore)
  6257. self.widgets[ptype].set_active(2)
  6258. try:
  6259. signalindex = hal_pwm_output_names.index(datap)
  6260. except:
  6261. if debug: print "**** INFO: PNCCONF warning no PWM / PDM signal named: %s\n found for pin %s"% (datap ,p)
  6262. signalindex = 0
  6263. #print "dataptype:",self.data[ptype]," dataptype:",self.data[p],signalindex
  6264. count = -2
  6265. if signalindex > 0:
  6266. #print "\n parsing PWM names"
  6267. for row,parent in enumerate(human_pwm_output_names):
  6268. if row == 0: continue
  6269. if len(parent[1]) == 0:
  6270. count += 3
  6271. #print row,count,"parent-",parent[0]
  6272. if count == signalindex:
  6273. #print "match",row
  6274. temp = (row)
  6275. break
  6276. continue
  6277. #print "parsing child"
  6278. for column,child in enumerate(parent[1]):
  6279. count +=3
  6280. #print row,column,count,parent[0],child
  6281. if count == signalindex:
  6282. #print "match",row
  6283. temp = (row,column)
  6284. break
  6285. if count >= signalindex:break
  6286. else:
  6287. temp = (0) # set unused pwm
  6288. #print "temp",temp
  6289. treeiter = self.data._pwmsignaltree.get_iter(temp)
  6290. self.widgets[p].set_active_iter(treeiter)
  6291. # type tp 3 pwm for direct brushless motor control
  6292. elif widgetptype == TPPWMA:
  6293. #print "3 pwm"
  6294. count = -7
  6295. try:
  6296. signalindex = hal_tppwm_output_names.index(datap)
  6297. except:
  6298. if debug: print "**** INFO: PNCCONF warning no THREE PWM signal named: %s\n found for pin %s"% (datap ,p)
  6299. signalindex = 0
  6300. #print "3 PWw ,dataptype:",self.data[ptype]," dataptype:",self.data[p],signalindex
  6301. if signalindex > 0:
  6302. for row,parent in enumerate(human_tppwm_output_names):
  6303. if row == 0:continue
  6304. if len(parent[1]) == 0:
  6305. count += 8
  6306. #print row,count,parent[0]
  6307. if count == signalindex:
  6308. #print "match",row
  6309. temp = (row)
  6310. break
  6311. continue
  6312. for column,child in enumerate(parent[1]):
  6313. count +=8
  6314. #print row,column,count,parent[0],child
  6315. if count == signalindex:
  6316. #print "match",row
  6317. temp = (row,column)
  6318. break
  6319. if count >= signalindex:break
  6320. else:
  6321. temp = (0) # set unused stepper
  6322. treeiter = self.data._tppwmsignaltree.get_iter(temp)
  6323. self.widgets[p].set_active_iter(treeiter)
  6324. # type step gen
  6325. elif widgetptype == STEPA:
  6326. #print "stepper", dataptype
  6327. self.widgets[ptype].set_active(0)
  6328. self.widgets[p].set_active(0)
  6329. self.widgets[pinv].set_active(datapinv)
  6330. try:
  6331. signalindex = hal_stepper_names.index(self.data[p])
  6332. except:
  6333. if debug: print "**** INFO: PNCCONF warning no STEPPER signal named: %s\n found for pin %s"% (datap ,p)
  6334. signalindex = 0
  6335. count = -5
  6336. #print "stepper,dataptype:",self.data[ptype]," dataptype:",self.data[p],signalindex
  6337. if signalindex > 0:
  6338. for row,parent in enumerate(human_stepper_names):
  6339. if row == 0:continue
  6340. if len(parent[1]) == 0:
  6341. count += 6
  6342. #print row,count,parent[0]
  6343. if count == signalindex:
  6344. #print "match",row
  6345. temp = (row)
  6346. break
  6347. continue
  6348. for column,child in enumerate(parent[1]):
  6349. count +=6
  6350. #print row,column,count,parent[0],child
  6351. if count == signalindex:
  6352. #print "match",row
  6353. temp = (row,column)
  6354. break
  6355. if count >= signalindex:break
  6356. else:
  6357. temp = (0) # set unused stepper
  6358. treeiter = self.data._steppersignaltree.get_iter(temp)
  6359. self.widgets[p].set_active_iter(treeiter)
  6360. # type smartserial
  6361. elif widgetptype in( TXDATA0,SS7I76M0,SS7I77M0,SS7I77M3,TXDATA1,TXDATA2,TXDATA3,TXDATA4,TXDATA5,TXDATA6,TXDATA7,
  6362. SS7I76M2,SS7I76M3,SS7I77M1,SS7I77M4):
  6363. #print "SMART SERIAL", dataptype,widgetptype
  6364. self.widgets[pinv].set_active(datapinv)
  6365. try:
  6366. signalindex = hal_sserial_names.index(self.data[p])
  6367. except:
  6368. if debug: print "**** INFO: PNCCONF warning no SMART SERIAL signal named: %s\n found for pin %s"% (datap ,p)
  6369. signalindex = 0
  6370. count = -2
  6371. #print "sserial,dataptype:",self.data[ptype]," dataptype:",self.data[p],signalindex
  6372. if signalindex > 0:
  6373. for row,parent in enumerate(human_sserial_names):
  6374. if row == 0:continue
  6375. if len(parent[1]) == 0:
  6376. count += 3
  6377. #print row,count,parent[0]
  6378. if count == signalindex:
  6379. #print "match",row
  6380. temp = (row)
  6381. break
  6382. continue
  6383. else:
  6384. temp = (0) # set unused sserial
  6385. treeiter = self.data._sserialsignaltree.get_iter(temp)
  6386. self.widgets[p].set_active_iter(treeiter)
  6387. else:
  6388. print "**** WARNING: PNCCONF data to widget: ptype not recognized/match:",dataptype,widgetptype
  6389. def fill_pintype_model(self):
  6390. # notused
  6391. self.data._notusedliststore = gtk.ListStore(str,int)
  6392. self.data._notusedliststore.append([pintype_notused[0],0])
  6393. # gpio
  6394. self.data._gpioliststore = gtk.ListStore(str,int)
  6395. for number,text in enumerate(pintype_gpio):
  6396. self.data._gpioliststore.append([text,0])
  6397. # stepper
  6398. self.data._stepperliststore = gtk.ListStore(str,int)
  6399. for number,text in enumerate(pintype_stepper):
  6400. self.data._stepperliststore.append([text,number])
  6401. # encoder
  6402. self.data._encoderliststore = gtk.ListStore(str,int)
  6403. for number,text in enumerate(pintype_encoder):
  6404. self.data._encoderliststore.append([text,number])
  6405. # mux encoder
  6406. self.data._muxencoderliststore = gtk.ListStore(str,int)
  6407. for number,text in enumerate(pintype_muxencoder):
  6408. self.data._muxencoderliststore.append([text,number])
  6409. # resolver
  6410. self.data._resolverliststore = gtk.ListStore(str,int)
  6411. for number,text in enumerate(pintype_resolver):
  6412. self.data._resolverliststore.append([text,number])
  6413. # 8i20 AMP
  6414. self.data._8i20liststore = gtk.ListStore(str,int)
  6415. for number,text in enumerate(pintype_8i20):
  6416. self.data._8i20liststore.append([text,number])
  6417. # potentiometer output
  6418. self.data._potliststore = gtk.ListStore(str,int)
  6419. for number,text in enumerate(pintype_potentiometer):
  6420. self.data._potliststore.append([text,number])
  6421. # analog input
  6422. self.data._analoginliststore = gtk.ListStore(str,int)
  6423. for number,text in enumerate(pintype_analog_in):
  6424. self.data._analoginliststore.append([text,number])
  6425. # pwm
  6426. self.data._pwmrelatedliststore = gtk.ListStore(str,int)
  6427. for number,text in enumerate(pintype_pwm):
  6428. self.data._pwmrelatedliststore.append([text,number])
  6429. self.data._pwmcontrolliststore = gtk.ListStore(str,int)
  6430. self.data._pwmcontrolliststore.append([pintype_pwm[0],0])
  6431. self.data._pwmcontrolliststore.append([pintype_pdm[0],0])
  6432. self.data._pwmcontrolliststore.append([pintype_udm[0],0])
  6433. # pdm
  6434. self.data._pdmrelatedliststore = gtk.ListStore(str,int)
  6435. for number,text in enumerate(pintype_pdm):
  6436. self.data._pdmrelatedliststore.append([text,number])
  6437. self.data._pdmcontrolliststore = gtk.ListStore(str,int)
  6438. self.data._pdmcontrolliststore.append([pintype_pwm[0],0])
  6439. self.data._pdmcontrolliststore.append([pintype_pdm[0],0])
  6440. self.data._pdmcontrolliststore.append([pintype_udm[0],0])
  6441. # udm
  6442. self.data._udmrelatedliststore = gtk.ListStore(str,int)
  6443. for number,text in enumerate(pintype_udm):
  6444. self.data._udmrelatedliststore.append([text,number])
  6445. self.data._udmcontrolliststore = gtk.ListStore(str,int)
  6446. self.data._udmcontrolliststore.append([pintype_pwm[0],0])
  6447. self.data._udmcontrolliststore.append([pintype_pdm[0],0])
  6448. self.data._udmcontrolliststore.append([pintype_udm[0],0])
  6449. #tppwm
  6450. self.data._tppwmliststore = gtk.ListStore(str,int)
  6451. for number,text in enumerate(pintype_tp_pwm):
  6452. self.data._tppwmliststore.append([text,number])
  6453. #sserial
  6454. self.data._sserialliststore = gtk.ListStore(str,int)
  6455. for number,text in enumerate(pintype_sserial):
  6456. self.data._sserialliststore.append([text,number])
  6457. def fill_combobox_models(self):
  6458. templist = [ ["_gpioosignaltree",human_output_names,1],["_gpioisignaltree",human_input_names,1],
  6459. ["_encodersignaltree",human_encoder_input_names,4],["_resolversignaltree",human_resolver_input_names,1],
  6460. ["_pwmsignaltree",human_pwm_output_names,3],["_tppwmsignaltree",human_tppwm_output_names,8],
  6461. ["_steppersignaltree",human_stepper_names,6],
  6462. ["_muxencodersignaltree",human_encoder_input_names,4],
  6463. ["_8i20signaltree",human_8i20_input_names,1], ["_potsignaltree",human_pot_output_names,2],
  6464. ["_analoginsignaltree",human_analog_input_names,1],["_sserialsignaltree",human_sserial_names,3]]
  6465. for item in templist:
  6466. #print "\ntype",item[0]
  6467. count = 0
  6468. end = len(item[1])-1
  6469. self.data[item[0]]= gtk.TreeStore(str,int)
  6470. for i,parent in enumerate(item[1]):
  6471. if len(parent[1]) == 0:
  6472. # if combobox has a 'custom' signal choice then the index must be 0
  6473. if i == end and not item[0] =="_sserialsignaltree":temp = 0
  6474. else:temp = count
  6475. #print parent,temp,count
  6476. #print "length of human names:",len(parent[1])
  6477. # this adds the index number (temp) of the signal
  6478. piter = self.data[item[0]].append(None, [parent[0], temp])
  6479. if count == 0: count = 1
  6480. else: count +=item[2]
  6481. else:
  6482. #print "parsing child"
  6483. piter = self.data[item[0]].append(None, [parent[0],0])
  6484. for j,child in enumerate(parent[1]):
  6485. #print i,count,parent[0],child
  6486. self.data[item[0]].append(piter, [child, count])
  6487. count +=item[2]
  6488. self.data._notusedsignaltree = gtk.TreeStore(str,int)
  6489. self.data._notusedsignaltree.append(None, [human_notused_names[0][0],0])
  6490. # This is for when a user picks a signal name or creates a custom signal (by pressing enter)
  6491. # if searches for the 'related pins' of a component so it can update them too
  6492. # it also handles adding and updating custom signal names
  6493. # it is used for mesa boards and parport boards according to boardtype
  6494. def on_general_pin_changed(self, widget, boardtype, boardnum, connector, channel, pin, custom):
  6495. if boardtype == "sserial":
  6496. p = 'mesa%dsserial%d_%dpin%d' % (boardnum,connector,channel,pin)
  6497. ptype = 'mesa%dsserial%d_%dpin%dtype' % (boardnum,connector,channel,pin)
  6498. widgetptype = self.widgets[ptype].get_active_text()
  6499. #print "pinchaned-",p
  6500. elif boardtype == "mesa":
  6501. p = 'mesa%dc%dpin%d' % (boardnum,connector,pin)
  6502. ptype = 'mesa%dc%dpin%dtype' % (boardnum,connector,pin)
  6503. widgetptype = self.widgets[ptype].get_active_text()
  6504. elif boardtype == "parport":
  6505. p = '%s%s%d' % (boardnum,connector, pin)
  6506. #print p
  6507. if "I" in p: widgetptype = GPIOI
  6508. else: widgetptype = GPIOO
  6509. pinchanged = self.widgets[p].get_active_text()
  6510. piter = self.widgets[p].get_active_iter()
  6511. #print "generalpin changed",p
  6512. #print "*** INFO ",boardtype,"-pin-changed: pin:",p,"custom:",custom
  6513. #print "*** INFO ",boardtype,"-pin-changed: ptype:",widgetptype,"pinchaanged:",pinchanged
  6514. if piter == None and not custom:
  6515. #print "*** INFO ",boardtype,"-pin-changed: no iter and not custom"
  6516. return
  6517. if widgetptype in (ENCB,ENCI,ENCM,
  6518. MXEI,MXEM,MXES,
  6519. RESU,
  6520. STEPB,STEPC,STEPD,STEPE,STEPF,
  6521. PDMD,PDME,PWMD,PWME,UDMD,UDME,
  6522. TPPWMB,TPPWMC,TPPWMAN,TPPWMBN,TPPWMCN,TPPWME,TPPWMF,
  6523. RXDATA0,TXEN0,RXDATA1,TXEN1,RXDATA2,TXEN2,RXDATA3,TXEN3,
  6524. POTE,POTD
  6525. ):return
  6526. # for GPIO output
  6527. if widgetptype in (GPIOO,GPIOD):
  6528. #print"ptype GPIOO\n"
  6529. signaltree = self.data._gpioosignaltree
  6530. halsignallist = hal_output_names
  6531. humansignallist = human_output_names
  6532. addsignalto = self.data.haloutputsignames
  6533. relatedsearch = ["dummy"]
  6534. relatedending = [""]
  6535. customindex = 10
  6536. # for GPIO input
  6537. elif widgetptype == GPIOI:
  6538. #print"ptype GPIOI\n"
  6539. signaltree = self.data._gpioisignaltree
  6540. halsignallist = hal_input_names
  6541. humansignallist = human_input_names
  6542. addsignalto = self.data.halinputsignames
  6543. relatedsearch = ["dummy"]
  6544. relatedending = [""]
  6545. customindex = 16
  6546. # for stepgen pins
  6547. elif widgetptype == STEPA:
  6548. #print"ptype step\n"
  6549. signaltree = self.data._steppersignaltree
  6550. halsignallist = hal_stepper_names
  6551. humansignallist = human_stepper_names
  6552. addsignalto = self.data.halsteppersignames
  6553. relatedsearch = [STEPA,STEPB,STEPC,STEPD,STEPE,STEPF]
  6554. relatedending = ["-step","-dir","-c","-d","-e","-f"]
  6555. customindex = 6
  6556. # for encoder pins
  6557. elif widgetptype == ENCA:
  6558. #print"\nptype encoder"
  6559. signaltree = self.data._encodersignaltree
  6560. halsignallist = hal_encoder_input_names
  6561. humansignallist = human_encoder_input_names
  6562. addsignalto = self.data.halencoderinputsignames
  6563. relatedsearch = [ENCA,ENCB,ENCI,ENCM]
  6564. relatedending = ["-a","-b","-i","-m"]
  6565. customindex = 4
  6566. # for mux encoder pins
  6567. elif widgetptype in(MXE0,MXE1):
  6568. #print"\nptype encoder"
  6569. signaltree = self.data._muxencodersignaltree
  6570. halsignallist = hal_encoder_input_names
  6571. humansignallist = human_encoder_input_names
  6572. addsignalto = self.data.halencoderinputsignames
  6573. relatedsearch = ["dummy","dummy","dummy","dummy",]
  6574. relatedending = ["-a","-b","-i","-m"]
  6575. customindex = 4
  6576. # resolvers
  6577. elif widgetptype in (RES0,RES1,RES2,RES3,RES4,RES5):
  6578. signaltree = self.data._resolversignaltree
  6579. halsignallist = hal_resolver_input_names
  6580. humansignallist = human_resolver_input_names
  6581. addsignalto = self.data.halresolversignames
  6582. relatedsearch = ["dummy"]
  6583. relatedending = [""]
  6584. customindex = 1
  6585. # 8i20 amplifier
  6586. elif widgetptype == AMP8I20:
  6587. signaltree = self.data._8i20signaltree
  6588. halsignallist = hal_8i20_input_names
  6589. humansignallist = human_8i20_input_names
  6590. addsignalto = self.data.hal8i20signames
  6591. relatedsearch = ["dummy"]
  6592. relatedending = [""]
  6593. customindex = 1
  6594. # potentiometer output
  6595. elif widgetptype == POTO:
  6596. signaltree = self.data._potsignaltree
  6597. halsignallist = hal_pot_output_names
  6598. humansignallist = human_pot_output_names
  6599. addsignalto = self.data.halpotsignames
  6600. relatedsearch = [POTO,POTE]
  6601. relatedending = ["-output","-enable"]
  6602. customindex = 2
  6603. # analog input
  6604. elif widgetptype == ANALOGIN:
  6605. signaltree = self.data._analoginsignaltree
  6606. halsignallist = hal_analog_input_names
  6607. humansignallist = human_analog_input_names
  6608. addsignalto = self.data.halanaloginsignames
  6609. relatedsearch = ["dummy"]
  6610. relatedending = [""]
  6611. customindex = 1
  6612. # for PWM,PDM,UDM pins
  6613. elif widgetptype in(PWMP,PDMP,UDMU):
  6614. #print"ptype pwmp\n"
  6615. signaltree = self.data._pwmsignaltree
  6616. halsignallist = hal_pwm_output_names
  6617. humansignallist = human_pwm_output_names
  6618. addsignalto = self.data.halpwmoutputsignames
  6619. relatedsearch = [PWMP,PWMD,PWME]
  6620. relatedending = ["-pulse","-dir","-enable"]
  6621. customindex = 6
  6622. elif widgetptype == TPPWMA:
  6623. #print"ptype pdmp\n"
  6624. signaltree = self.data._tppwmsignaltree
  6625. halsignallist = hal_tppwm_output_names
  6626. humansignallist = human_tppwm_output_names
  6627. addsignalto = self.data.haltppwmoutputsignames
  6628. relatedsearch = [TPPWMA,TPPWMB,TPPWMC,TPPWMAN,TPPWMBN,TPPWMCN,TPPWME,TPPWMF]
  6629. relatedending = ["-a","-b","c","-anot","-bnot","cnot","-enable","-fault"]
  6630. customindex = 6
  6631. elif widgetptype in (TXDATA0,TXDATA1,TXDATA2,TXDATA3,TXDATA4,SS7I76M0,SS7I76M3,SS7I76M2,SS7I77M0,SS7I77M1,SS7I77M3,SS7I77M4):
  6632. portnum = 0 #TODO support more ports
  6633. for count,temp in enumerate(self.data["mesa%d_currentfirmwaredata"% boardnum][_NUMOFCNCTRS]) :
  6634. if connector == temp:
  6635. firmptype,portnum = self.data["mesa%d_currentfirmwaredata"% boardnum][_STARTOFDATA+pin+(count*24)]
  6636. if widgetptype in (TXDATA0,SS7I76M0,SS7I77M0): channelnum = 0
  6637. elif widgetptype in (TXDATA1,SS7I77M1): channelnum = 1
  6638. elif widgetptype in (TXDATA2,SS7I76M2): channelnum = 2
  6639. elif widgetptype in (TXDATA3,SS7I77M3,SS7I76M3): channelnum = 3
  6640. elif widgetptype in (TXDATA4,SS7I77M4): channelnum = 4
  6641. if self.widgets[p].get_active_text() == _("Unused Channel"):
  6642. self.widgets["mesa%dsserial0_%d"% (boardnum,channelnum)].hide()
  6643. self.data["mesa%dsserial%d_%dsubboard"% (boardnum, portnum, channelnum)] = "none"
  6644. return
  6645. else:
  6646. self.widgets["mesa%dsserial0_%d"% (boardnum,channelnum)].show()
  6647. # TODO we should search for these names rather then use hard coded logic
  6648. # so as to make adding cards easier
  6649. temp = self.widgets[p].get_active_text()
  6650. table = "mesa%dsserial%d_%dtable2"% (boardnum, portnum, channelnum)
  6651. self.widgets[table].show()
  6652. table = "mesa%dsserial%d_%dtable3"% (boardnum, portnum, channelnum)
  6653. self.widgets[table].show()
  6654. if "7i76" in temp:
  6655. self.data["mesa%dsserial%d_%dsubboard"% (boardnum, portnum, channelnum)] = "7i76-m0"
  6656. elif "7i64" in temp:
  6657. self.data["mesa%dsserial%d_%dsubboard"% (boardnum, portnum, channelnum)] = "7i64"
  6658. elif "7i69" in temp:
  6659. self.data["mesa%dsserial%d_%dsubboard"% (boardnum, portnum, channelnum)] = "7i69"
  6660. self.widgets[table].hide()
  6661. elif "7i70" in temp:
  6662. self.data["mesa%dsserial%d_%dsubboard"% (boardnum, portnum, channelnum)] = "7i70"
  6663. self.widgets[table].hide()
  6664. elif "7i71" in temp:
  6665. self.data["mesa%dsserial%d_%dsubboard"% (boardnum, portnum, channelnum)] = "7i71"
  6666. self.widgets[table].hide()
  6667. elif "7i73" in temp:
  6668. self.data["mesa%dsserial%d_%dsubboard"% (boardnum, portnum, channelnum)] = "7i73-m1"
  6669. elif "7i77" in temp:
  6670. self.data["mesa%dsserial%d_%dsubboard"% (boardnum, portnum, channelnum)] = "7i77-m0"
  6671. if channelnum in(0,3):
  6672. self.widgets[table].hide()
  6673. elif channelnum in(1,4):
  6674. table = "mesa%dsserial%d_%dtable2"% (boardnum, portnum, channelnum)
  6675. self.widgets[table].hide()
  6676. table = "mesa%dsserial%d_%dtable1"% (boardnum, portnum, channelnum)
  6677. self.widgets[table].hide()
  6678. elif "8i20" in temp:
  6679. self.data["mesa%dsserial%d_%dsubboard"% (boardnum, portnum, channelnum)] = "8i20"
  6680. self.widgets[table].hide()
  6681. table = "mesa%dsserial%d_%dtable2"% (boardnum, portnum, channelnum)
  6682. self.widgets[table].hide()
  6683. else:
  6684. self.data["mesa%dsserial%d_%dsubboard"% (boardnum, portnum, channelnum)] = "none"
  6685. self.widgets[table].hide()
  6686. table = "mesa%dsserial%d_%dtable2"% (boardnum, portnum, channelnum)
  6687. self.widgets[table].hide()
  6688. table = "mesa%dsserial%d_%dtable1"% (boardnum, portnum, channelnum)
  6689. self.widgets[table].hide()
  6690. return
  6691. # set sserial tab names to corresond to connector numbers so users have a clue
  6692. # first we have to find the daughter board in pncconf's internal list
  6693. # TODO here we search the list- this should be done for the table names see above todo
  6694. subfirmname = self.data["mesa%dsserial%d_%dsubboard"% (boardnum, portnum, channelnum)]
  6695. for subnum,temp in enumerate(mesadaughterdata):
  6696. if mesadaughterdata[subnum][_SUBFIRMNAME] == subfirmname: break
  6697. subconlist = mesadaughterdata[subnum][_SUBCONLIST]
  6698. # now search the connector list and write it to the tab names
  6699. for tabnum in range(0,3):
  6700. conname = subconlist[tabnum]
  6701. tab = "mesa%dsserial%d_%dtab%d"% (boardnum, portnum, channelnum,tabnum)
  6702. self.widgets[tab].set_text(conname)
  6703. #print p,temp," set at",self.data["mesa%dsserial%d_%dsubboard"% (boardnum, portnum, channelnum)]
  6704. self.set_sserial_options(boardnum,portnum,channelnum)
  6705. return
  6706. return
  6707. else:
  6708. print"**** INFO: pncconf on_general_pin_changed: pintype not found:%s\n"% widgetptype
  6709. return
  6710. # *** change the related pin's signal names ***
  6711. # see if the piter is none - if it is a custom names has been entered
  6712. # else find the signal name index number if the index is zero set the piter to unused signal
  6713. # this is a work around for thye combo box allowing the parent to be shown and selected in the
  6714. # child column haven\t figured out how to stop that #TODO
  6715. # either way we have to search the current firmware array for the pin numbers of the related
  6716. # pins so we can change them to the related signal name
  6717. # all signal names have related signal (eg encoders have A and B phase and index and index mask)
  6718. # except 'unused' signal it is a special case as there is no related signal names with it.
  6719. if piter == None or custom:
  6720. #print "*** INFO ",boardtype,"-pin-changed: PITER:",piter," length:",len(signaltree)
  6721. if pinchanged in (addsignalto):return
  6722. for i in (humansignallist):
  6723. if pinchanged == i[0]:return
  6724. if pinchanged in i[1]:return
  6725. length = len(signaltree)
  6726. index = len(halsignallist) - len(relatedsearch)
  6727. customiter = signaltree.get_iter((length-1,))
  6728. childiter = signaltree.iter_nth_child(customiter, 0)
  6729. n = 0
  6730. while childiter:
  6731. dummy, index = signaltree.get(childiter, 0, 1)
  6732. n+=1
  6733. childiter = signaltree.iter_nth_child(customiter, n)
  6734. index += len(relatedsearch)
  6735. else:
  6736. dummy, index = signaltree.get(piter, 0, 1)
  6737. if index == 0:
  6738. piter = signaltree.get_iter_first()
  6739. #print "*** INFO ",boardtype,"-pin-changed: index",index
  6740. # This finds the pin type and component number of the pin that has changed
  6741. pinlist = []
  6742. # this components have no related pins - fake the list
  6743. if widgetptype in(GPIOI,GPIOO,GPIOD,MXE0,MXE1,RES0,RES1,RES2,RES3,RES4,RES5,AMP8I20,ANALOGIN):
  6744. pinlist = [["%s"%p,boardnum,connector,channel,pin]]
  6745. else:
  6746. pinlist = self.data.list_related_pins(relatedsearch, boardnum, connector, channel, pin, 0)
  6747. #print pinlist
  6748. # Now we have a list of pins that need to be updated
  6749. # first check if the name is a custom name if it is
  6750. # add the legalized custom name to ;
  6751. # addsignalto -> for recording custom names for next time loaded
  6752. # signalsto check -> for making signal names (we add different endings for different signalnames
  6753. # signaltree -> for display in the gui - itis automatically added to all comboboxes that uses this treesort
  6754. # then go through the pinlist:
  6755. # block signals
  6756. # display the proper text depending if custom or not
  6757. # then unblock signals
  6758. if custom:
  6759. legal_name = pinchanged.replace(" ","_")
  6760. addsignalto.append ((legal_name))
  6761. #print "add"+legal_name+"to human list"
  6762. humansignallist[customindex][1].append ((legal_name))
  6763. endoftree = len(signaltree)-1
  6764. customiter = signaltree.get_iter((endoftree,))
  6765. newiter = signaltree.append(customiter, [legal_name,index])
  6766. for offset,i in enumerate(relatedsearch):
  6767. with_endings = legal_name + relatedending[offset]
  6768. #print "new signal:",with_endings
  6769. halsignallist.append ((with_endings))
  6770. for data in(pinlist):
  6771. if boardtype == "mesa":
  6772. blocksignal1 = "_mesa%dsignalhandlerc%ipin%i" % (data[1], data[2], data[4])
  6773. blocksignal2 = "_mesa%dactivatehandlerc%ipin%i" % (data[1], data[2], data[4])
  6774. if boardtype == "sserial":
  6775. blocksignal1 = "_mesa%dsignalhandlersserial%i_%ipin%i" % (data[1], data[2], data[3], data[4])
  6776. blocksignal2 = "_mesa%dactivatehandlersserial%i_%ipin%i" % (data[1], data[2], data[3],data[4])
  6777. elif boardtype =="parport":
  6778. blocksignal1 = "_%s%s%dsignalhandler" % (data[1], data[2], data[4])
  6779. blocksignal2 = "_%s%s%dactivatehandler" % (data[1], data[2], data[4])
  6780. self.widgets[data[0]].handler_block(self.data[blocksignal1])
  6781. self.widgets[data[0]].child.handler_block(self.data[blocksignal2])
  6782. if custom:
  6783. self.widgets[data[0]].set_active_iter(newiter)
  6784. else:
  6785. self.widgets[data[0]].set_active_iter(piter)
  6786. self.widgets[data[0]].child.handler_unblock(self.data[blocksignal2])
  6787. self.widgets[data[0]].handler_unblock(self.data[blocksignal1])
  6788. #self.debug_iter(0,p,"pin changed")
  6789. #if boardtype == "mesa": self.debug_iter(0,ptype,"pin changed")
  6790. def on_pp1pport_prepare(self, *args):
  6791. self.data.help = 5
  6792. self.in_pport_prepare = True
  6793. self.prepare_parport("pp1")
  6794. c = self.data.pp1_direction
  6795. if c:
  6796. self.widgets.pp1pport.set_title(_("First Parallel Port set for OUTPUT"))
  6797. else:
  6798. self.widgets.pp1pport.set_title(_("First Parallel Port set for INPUT"))
  6799. def on_pp1pport_next(self, *args):
  6800. self.next_parport("pp1")
  6801. if self.data.number_pports<2:
  6802. self.widgets.druid1.set_page(self.widgets.xaxismotor)
  6803. return True
  6804. def on_pp1pport_back(self, *args):
  6805. if self.data.number_mesa == 2:
  6806. self.widgets.druid1.set_page(self.widgets.mesa1)
  6807. return True
  6808. elif self.data.number_mesa == 1:
  6809. self.widgets.druid1.set_page(self.widgets.mesa0)
  6810. return True
  6811. elif not self.data.number_mesa:
  6812. self.widgets.druid1.set_page(self.widgets.GUIconfig)
  6813. return True
  6814. def on_pp2pport_prepare(self, *args):
  6815. self.data.help = 5
  6816. self.prepare_parport("pp2")
  6817. c = self.data.pp2_direction
  6818. if c:
  6819. self.widgets.pp2pport.set_title(_("Second Parallel Port set for OUTPUT"))
  6820. else:
  6821. self.widgets.pp2pport.set_title(_("Second Parallel Port set for INPUT"))
  6822. def on_pp2pport_next(self, *args):
  6823. self.next_parport("pp2")
  6824. if self.data.number_pports<3:
  6825. self.widgets.druid1.set_page(self.widgets.xaxismotor)
  6826. return True
  6827. def on_pp3pport_prepare(self, *args):
  6828. self.prepare_parport("pp3")
  6829. c = self.data.pp3_direction
  6830. if c:
  6831. self.widgets.pp3pport.set_title(_("Third Parallel Port set for OUTPUT"))
  6832. else:
  6833. self.widgets.pp3pport.set_title(_("Third Parallel Port set for INPUT"))
  6834. def on_pp3pport_next(self, *args):
  6835. self.data.help = 5
  6836. self.next_parport("pp3")
  6837. def prepare_parport(self,portname):
  6838. self.data.help = "help-parport.txt"
  6839. def set_combo(dataptype,p):
  6840. # signal names for GPIO INPUT
  6841. datap = self.data[p]
  6842. if dataptype == GPIOI:
  6843. human = human_input_names
  6844. signal = hal_input_names
  6845. tree = self.data._gpioisignaltree
  6846. # signal names for GPIO OUTPUT and OPEN DRAIN OUTPUT
  6847. elif dataptype in (GPIOO,GPIOD):
  6848. human = human_output_names
  6849. signal = hal_output_names
  6850. tree = self.data._gpioosignaltree
  6851. self.widgets[p].set_model(tree)
  6852. # an error probably means the signal name cannot be found
  6853. # set it as unused rather then error
  6854. try:
  6855. signalindex = signal.index(datap)
  6856. except:
  6857. signalindex = 0
  6858. print "**** INFO: PNCCONF warning no GPIO signal named: %s\n found for pin %s"% (datap , p)
  6859. #print "gpio temp ptype:",dataptype,datap,signalindex
  6860. count = 0
  6861. temp = (0) # set unused gpio if no match
  6862. if signalindex > 0:
  6863. for row,parent in enumerate(human):
  6864. if len(parent[1]) == 0:continue
  6865. for column,child in enumerate(parent[1]):
  6866. count +=1
  6867. #print row,column,count,parent[0],child
  6868. if count == signalindex:
  6869. #print "match",row,column
  6870. break
  6871. if count >= signalindex:break
  6872. temp = (row,column)
  6873. treeiter = tree.get_iter(temp)
  6874. self.widgets[p].set_active_iter(treeiter)
  6875. for pin in (1,2,3,4,5,6,7,8,9,14,16,17):
  6876. p = '%sOpin%d' % (portname,pin)
  6877. set_combo(GPIOO,p)
  6878. p = '%sOpin%dinv' % (portname, pin)
  6879. self.widgets[p].set_active(self.data[p])
  6880. for pin in (2,3,4,5,6,7,8,9,10,11,12,13,15):
  6881. p = '%sIpin%d' % (portname, pin)
  6882. set_combo(GPIOI,p)
  6883. p = '%sIpin%dinv' % (portname, pin)
  6884. self.widgets[p].set_active(self.data[p])
  6885. self.in_pport_prepare = False
  6886. c = self.data[portname+"_direction"]
  6887. for pin in (2,3,4,5,6,7,8,9):
  6888. p = '%sOpin%dlabel' % (portname, pin)
  6889. self.widgets[p].set_sensitive(c)
  6890. p = '%sOpin%dinv' % (portname, pin)
  6891. self.widgets[p].set_sensitive(c)
  6892. p = '%sOpin%d' % (portname, pin)
  6893. self.widgets[p].set_sensitive(c)
  6894. if not c :self.widgets[p].set_active(hal_output_names.index("unused-output"))
  6895. p = '%sIpin%dlabel' % (portname, pin)
  6896. self.widgets[p].set_sensitive(not c)
  6897. p = '%sIpin%d' % (portname, pin)
  6898. self.widgets[p].set_sensitive(not c)
  6899. if c :self.widgets[p].set_active(hal_input_names.index("unused-input"))
  6900. p = '%sIpin%dinv' % (portname, pin)
  6901. self.widgets[p].set_sensitive(not c)
  6902. def next_parport(self,portname):
  6903. def push_data(port,direction,pin,pinv,signaltree,signaltocheck):
  6904. p = '%s%s%d' % (port, direction, pin)
  6905. piter = self.widgets[p].get_active_iter()
  6906. selection = self.widgets[p].get_active_text()
  6907. # **Start widget to data Convertion**
  6908. if piter == None:# means new custom signal name and user never pushed enter
  6909. #print "callin pin changed !!!"
  6910. self.on_general_pin_changed( None,"parport", port, direction, None, pin, True)
  6911. selection = self.widgets[p].get_active_text()
  6912. piter = self.widgets[p].get_active_iter()
  6913. #print "found signame -> ",selection," "
  6914. # ok we have a piter with a signal type now- lets convert it to a signalname
  6915. #print "**** INFO parport-data-transfer piter:",piter
  6916. #self.debug_iter(piter,p,"signal")
  6917. dummy, index = signaltree.get(piter,0,1)
  6918. #print "signaltree: ",dummy
  6919. self.data[p] = signaltocheck[index]
  6920. self.data[pinv] = self.widgets[pinv].get_active()
  6921. #check input pins
  6922. for pin in (2,3,4,5,6,7,8,9,10,11,12,13,15):
  6923. direction = "Ipin"
  6924. pinv = '%sIpin%dinv' % (portname, pin)
  6925. signaltree = self.data._gpioisignaltree
  6926. signaltocheck = hal_input_names
  6927. push_data(portname,direction,pin,pinv,signaltree,signaltocheck)
  6928. # check output pins
  6929. for pin in (1,2,3,4,5,6,7,8,9,14,16,17):
  6930. direction = "Opin"
  6931. pinv = '%sOpin%dinv' % (portname, pin)
  6932. signaltree = self.data._gpioosignaltree
  6933. signaltocheck = hal_output_names
  6934. push_data(portname,direction,pin,pinv,signaltree,signaltocheck)
  6935. def on_parportpanel_clicked(self, *args):self.parporttest(self)
  6936. def signal_sanity_check(self, *args):
  6937. warnings = []
  6938. do_warning = False
  6939. for i in self.data.available_axes:
  6940. tppwm = pwm = amp_8i20 = False
  6941. step = self.data.findsignal(i+"-stepgen-step")
  6942. step2 = self.data.findsignal(i+"2-stepgen-step")
  6943. enc = self.data.findsignal(i+"-encoder-a")
  6944. resolver = self.data.findsignal(i+"-resolver")
  6945. if self.data.findsignal("%s-8i20"% i): amp_8i20 = pwm =True
  6946. if self.data.findsignal(i+"-pwm-pulse"): pwm = True
  6947. if self.data.findsignal(i+"-tppwm-a"): tppwm = pwm = True
  6948. #print "signal sanity check: axis",i,"\n pwm = ",pwm,"\n 3pwm =",tppwm,"\n encoder =",enc,"\n step=",step
  6949. if i == 's':
  6950. if step and pwm:
  6951. warnings.append(_("You can not have both steppers and pwm signals for spindle control\n") )
  6952. do_warning = True
  6953. continue
  6954. if not step and not pwm:
  6955. warnings.append(_("You forgot to designate a stepper or pwm signal for axis %s\n")% i)
  6956. do_warning = True
  6957. if pwm and not (enc or resolver):
  6958. warnings.append(_("You forgot to designate an encoder /resolver signal for axis %s servo\n")% i)
  6959. do_warning = True
  6960. if enc and not pwm and not step:
  6961. warnings.append(_("You forgot to designate a pwm signal or stepper signal for axis %s\n")% i)
  6962. do_warning = True
  6963. if step and pwm:
  6964. warnings.append(_("You can not have both steppers and pwm signals for axis %s\n")% i)
  6965. do_warning = True
  6966. if step2 and not step:
  6967. warnings.append(_("If using a tandem axis stepper, you must select a master stepgen for axis %s\n")% i)
  6968. do_warning = True
  6969. if self.data.frontend == _TOUCHY:# TOUCHY GUI
  6970. abort = self.data.findsignal("abort")
  6971. cycle = self.data.findsignal("cycle-start")
  6972. single = self.data.findsignal("single-step")
  6973. mpg = self.data.findsignal("select-mpg-a")
  6974. if not cycle:
  6975. warnings.append(_("Touchy require an external cycle start signal\n"))
  6976. do_warning = True
  6977. if not abort:
  6978. warnings.append(_("Touchy require an external abort signal\n"))
  6979. do_warning = True
  6980. if not single:
  6981. warnings.append(_("Touchy require an external single-step signal\n"))
  6982. do_warning = True
  6983. if not mpg:
  6984. warnings.append(_("Touchy require an external multi handwheel MPG encoder signal on the mesa page\n"))
  6985. do_warning = True
  6986. if not self.data.externalmpg:
  6987. warnings.append(_("Touchy require 'external mpg jogging' to be selected on the external control page\n"))
  6988. do_warning = True
  6989. if self.data.multimpg:
  6990. warnings.append(_("Touchy require the external mpg to be in 'shared mpg' mode on the external controls page\n"))
  6991. do_warning = True
  6992. if self.data.incrselect:
  6993. warnings.append(_("Touchy require selectable increments to be unchecked on the external controls page\n"))
  6994. do_warning = True
  6995. for boardnum in range(0,int(self.data.number_mesa)):
  6996. if self.data["mesa%d_sanity_7i29"%boardnum]:
  6997. warnings.append(_("The 7i29 daughter board requires PWM type generators and a PWM base frequency of 20 khz\n"))
  6998. do_warning = True
  6999. if self.data["mesa%d_sanity_7i30"%boardnum]:
  7000. warnings.append(_("The 7i30 daughter board requires PWM type generators and a PWM base frequency of 20 khz\n"))
  7001. do_warning = True
  7002. if self.data["mesa%d_sanity_7i33"%boardnum]:
  7003. warnings.append(_("The 7i33 daughter board requires PDM type generators and a PDM base frequency of 6 Mhz\n"))
  7004. do_warning = True
  7005. if self.data["mesa%d_sanity_7i40"%boardnum]:
  7006. warnings.append(_("The 7i40 daughter board requires PWM type generators and a PWM base frequency of 50 khz\n"))
  7007. do_warning = True
  7008. if self.data["mesa%d_sanity_7i48"%boardnum]:
  7009. warnings.append(_("The 7i48 daughter board requires UDM type generators and a PWM base frequency of 24 khz\n"))
  7010. do_warning = True
  7011. if do_warning: self.warning_dialog("\n".join(warnings),True)
  7012. def on_xaxismotor_prepare(self, *args):
  7013. self.data.help = "help-axismotor.txt"
  7014. self.axis_prepare('x')
  7015. def on_xaxismotor_next(self, *args):
  7016. self.data.help = "help-axisconfig.txt"
  7017. self.axis_done('x')
  7018. self.widgets.druid1.set_page(self.widgets.xaxis)
  7019. return True
  7020. def on_xaxismotor_back(self, *args):
  7021. self.axis_done('x')
  7022. if self.data.number_pports==1:
  7023. self.widgets.druid1.set_page(self.widgets.pp1pport)
  7024. return True
  7025. elif self.data.number_pports==2:
  7026. self.widgets.druid1.set_page(self.widgets.pp2pport)
  7027. return True
  7028. elif self.data.number_pports==3:
  7029. self.widgets.druid1.set_page(self.widgets.pp3pport)
  7030. return True
  7031. elif self.data.number_mesa == 2:
  7032. self.widgets.druid1.set_page(self.widgets.mesa1)
  7033. return True
  7034. elif self.data.number_mesa == 1:
  7035. self.widgets.druid1.set_page(self.widgets.mesa0)
  7036. return True
  7037. def on_yaxismotor_prepare(self, *args):
  7038. self.data.help = "help-axismotor.txt"
  7039. self.axis_prepare('y')
  7040. def on_yaxismotor_next(self, *args):
  7041. self.data.help = "help-axisconfig.txt"
  7042. self.axis_done('y')
  7043. self.widgets.druid1.set_page(self.widgets.yaxis)
  7044. return True
  7045. def on_yaxismotor_back(self, *args):
  7046. self.axis_done('y')
  7047. self.widgets.druid1.set_page(self.widgets.xaxis)
  7048. return True
  7049. def on_zaxismotor_prepare(self, *args):
  7050. self.data.help = "help-axismotor.txt"
  7051. self.axis_prepare('z')
  7052. def on_zaxismotor_next(self, *args):
  7053. self.data.help = "help-axisconfig.txt"
  7054. self.axis_done('z')
  7055. self.widgets.druid1.set_page(self.widgets.zaxis)
  7056. return True
  7057. def on_zaxismotor_back(self, *args):
  7058. self.axis_done('z')
  7059. if self.data.axes == 2:
  7060. self.widgets.druid1.set_page(self.widgets.xaxis)
  7061. return True
  7062. else:
  7063. self.widgets.druid1.set_page(self.widgets.yaxis)
  7064. return True
  7065. def on_aaxismotor_prepare(self, *args):
  7066. self.data.help = "help-axismotor.txt"
  7067. self.axis_prepare('a')
  7068. def on_aaxismotor_next(self, *args):
  7069. self.data.help = "help-axisconfig.txt"
  7070. self.axis_done('a')
  7071. self.widgets.druid1.set_page(self.widgets.aaxis)
  7072. return True
  7073. def on_aaxismotor_back(self, *args):
  7074. self.axis_done('a')
  7075. self.widgets.druid1.set_page(self.widgets.zaxis)
  7076. return True
  7077. def on_xcalculatescale_clicked(self, *args): self.calculate_scale('x')
  7078. def on_ycalculatescale_clicked(self, *args): self.calculate_scale('y')
  7079. def on_zcalculatescale_clicked(self, *args): self.calculate_scale('z')
  7080. def on_acalculatescale_clicked(self, *args): self.calculate_scale('a')
  7081. def on_scalculatescale_clicked(self, *args): self.calculate_scale('s')
  7082. def axis_prepare(self, axis):
  7083. d = self.data
  7084. w = self.widgets
  7085. def set_text(n): w[axis + n].set_text("%s" % d[axis + n])
  7086. def set_value(n): w[axis + n].set_value(d[axis + n])
  7087. def set_active(n): w[axis + n].set_active(d[axis + n])
  7088. stepdriven = encoder = pwmgen = resolver = tppwm = digital_at_speed = amp_8i20 = False
  7089. spindlepot = sserial_scaling = False
  7090. if self.data.findsignal("%s-8i20"% axis):amp_8i20 = True
  7091. if self.data.findsignal("spindle-at-speed"): digital_at_speed = True
  7092. if self.data.findsignal(axis+"-stepgen-step"): stepdriven = True
  7093. if self.data.findsignal(axis+"-encoder-a"): encoder = True
  7094. if self.data.findsignal(axis+"-resolver"): encoder = resolver = True
  7095. temp = self.data.findsignal(axis+"-pwm-pulse")
  7096. if temp:
  7097. pwmgen = True
  7098. pinname = self.data.make_pinname(temp)
  7099. if "analog" in pinname: sserial_scaling = True
  7100. if self.data.findsignal(axis+"-tppwm-a"): pwmgen = tppwm = True
  7101. if self.data.findsignal(axis+"-pot-output"): spindlepot = sserial_scaling = True
  7102. model = w[axis+"drivertype"].get_model()
  7103. model.clear()
  7104. for i in drivertypes:
  7105. model.append((i[1],))
  7106. model.append((_("Custom"),))
  7107. w["steprev"].set_text("%s" % d[axis+"steprev"])
  7108. w["microstep"].set_text("%s" % d[axis +"microstep"])
  7109. set_value("P")
  7110. set_value("I")
  7111. set_value("D")
  7112. set_value("FF0")
  7113. set_value("FF1")
  7114. set_value("FF2")
  7115. set_value("bias")
  7116. set_value("deadband")
  7117. set_value("steptime")
  7118. set_value("stepspace")
  7119. set_value("dirhold")
  7120. set_value("dirsetup")
  7121. set_value("outputscale")
  7122. set_value("outputminlimit")
  7123. set_value("outputmaxlimit")
  7124. set_value("3pwmscale")
  7125. set_value("3pwmdeadtime")
  7126. set_active("invertmotor")
  7127. set_active("invertencoder")
  7128. set_value("maxoutput")
  7129. if amp_8i20:
  7130. w[axis + "bldc_option"].set_active(True)
  7131. else:
  7132. set_active("bldc_option")
  7133. set_active("bldc_no_feedback")
  7134. set_active("bldc_absolute_feedback")
  7135. set_active("bldc_incremental_feedback")
  7136. set_active("bldc_use_hall")
  7137. set_active("bldc_use_encoder" )
  7138. set_active("bldc_use_index")
  7139. set_active("bldc_fanuc_alignment")
  7140. set_active("bldc_digital_output")
  7141. set_active("bldc_six_outputs")
  7142. set_active("bldc_emulated_feedback")
  7143. set_active("bldc_output_hall")
  7144. set_active("bldc_output_fanuc")
  7145. set_active("bldc_force_trapz")
  7146. set_active("bldc_reverse")
  7147. set_value("bldc_scale")
  7148. set_value("bldc_poles")
  7149. set_value("bldc_lead_angle")
  7150. set_value("bldc_inital_value")
  7151. set_value("bldc_encoder_offset")
  7152. set_value("bldc_drive_offset")
  7153. set_value("bldc_pattern_out")
  7154. set_value("bldc_pattern_in")
  7155. set_value("8i20maxcurrent")
  7156. w["motor_pulleydriver"].set_value(d[axis +"motor_pulleydriver"])
  7157. w["motor_pulleydriven"].set_value(d[axis +"motor_pulleydriven"])
  7158. w["encoder_pulleydriver"].set_value(d[axis +"encoder_pulleydriver"])
  7159. w["encoder_pulleydriven"].set_value(d[axis +"encoder_pulleydriven"])
  7160. w["motor_leadscrew_tpi"].set_value(d[axis +"motor_leadscrew_tpi"])
  7161. w["encoder_leadscrew_tpi"].set_value(d[axis +"encoder_leadscrew_tpi"])
  7162. w["motor_leadscrew"].set_value(d[axis +"motor_leadscrew"])
  7163. w["encoder_leadscrew"].set_value(d[axis +"encoder_leadscrew"])
  7164. w["encoderline"].set_value((d[axis+"encodercounts"]/4))
  7165. set_text("encodercounts")
  7166. set_value("stepscale")
  7167. set_value("encoderscale")
  7168. w[axis+"maxvel"].set_value(d[axis+"maxvel"]*60)
  7169. set_value("maxacc")
  7170. if encoder and not axis == "s":
  7171. w[axis + "servo_info"].show()
  7172. else:
  7173. w[axis + "servo_info"].hide()
  7174. if stepdriven:
  7175. w[axis + "output_info"].hide()
  7176. else:
  7177. w[axis + "output_info"].show()
  7178. w[axis + "invertencoder"].set_sensitive(encoder)
  7179. w[axis + "encoderscale"].set_sensitive(encoder)
  7180. w[axis + "stepscale"].set_sensitive(stepdriven)
  7181. if stepdriven:
  7182. w[axis + "stepper_info"].show()
  7183. else:
  7184. w[axis + "stepper_info"].hide()
  7185. if pwmgen or spindlepot:
  7186. w[axis + "outputscale"].show()
  7187. w[axis + "outputscalelabel"].show()
  7188. else:
  7189. w[axis + "outputscale"].hide()
  7190. w[axis + "outputscalelabel"].hide()
  7191. if sserial_scaling:
  7192. w[axis + "outputminlimit"].show()
  7193. w[axis + "outputminlimitlabel"].show()
  7194. w[axis + "outputmaxlimit"].show()
  7195. w[axis + "outputmaxlimitlabel"].show()
  7196. else:
  7197. w[axis + "outputminlimit"].hide()
  7198. w[axis + "outputminlimitlabel"].hide()
  7199. w[axis + "outputmaxlimit"].hide()
  7200. w[axis + "outputmaxlimitlabel"].hide()
  7201. if pwmgen or amp_8i20: w[axis + "bldcframe"].show()
  7202. else: w[axis + "bldcframe"].hide()
  7203. if tppwm:
  7204. w[axis + "3pwmdeadtime"].show()
  7205. w[axis + "3pwmscale"].show()
  7206. w[axis + "3pwmdeadtimelabel"].show()
  7207. w[axis + "3pwmscalelabel"].show()
  7208. else:
  7209. w[axis + "3pwmdeadtime"].hide()
  7210. w[axis + "3pwmscale"].hide()
  7211. w[axis + "3pwmdeadtimelabel"].hide()
  7212. w[axis + "3pwmscalelabel"].hide()
  7213. w[axis + "drivertype"].set_active(self.drivertype_toindex(axis))
  7214. if w[axis + "drivertype"].get_active_text() == _("Custom"):
  7215. w[axis + "steptime"].set_value(d[axis + "steptime"])
  7216. w[axis + "stepspace"].set_value(d[axis + "stepspace"])
  7217. w[axis + "dirhold"].set_value(d[axis + "dirhold"])
  7218. w[axis + "dirsetup"].set_value(d[axis + "dirsetup"])
  7219. gobject.idle_add(lambda: self.motor_encoder_sanity_check(None,axis))
  7220. if axis == "s":
  7221. unit = "rev"
  7222. pitchunit =_("Gearbox Reduction Ratio")
  7223. elif axis == "a":
  7224. unit = "degree"
  7225. pitchunit = _("Reduction Ratio")
  7226. elif d.units ==_METRIC:
  7227. unit = "mm"
  7228. pitchunit =_("Leadscrew Pitch")
  7229. else:
  7230. unit = "inch"
  7231. pitchunit =_("Leadscrew TPI")
  7232. if axis == "s" or axis =="a":
  7233. w["labelmotor_pitch"].set_text(pitchunit)
  7234. w["labelencoder_pitch"].set_text(pitchunit)
  7235. w["motor_screwunits"].set_text(_("("+unit+" / rev)"))
  7236. w["encoder_screwunits"].set_text(_("("+unit+" / rev)"))
  7237. w[axis + "velunits"].set_text(_(unit+" / min"))
  7238. w[axis + "accunits"].set_text(_(unit+" / sec²"))
  7239. w["accdistunits"].set_text(unit)
  7240. if stepdriven:
  7241. w[ "resolutionunits1"].set_text(_(unit+" / Step"))
  7242. w["scaleunits"].set_text(_("Steps / "+unit))
  7243. else:
  7244. w["resolutionunits1"].set_text(_(unit+" / encoder pulse"))
  7245. w["scaleunits"].set_text(_("Encoder pulses / "+unit))
  7246. if not axis =="s":
  7247. w[axis + "homevelunits"].set_text(_(unit+" / min"))
  7248. w[axis + "homelatchvelunits"].set_text(_(unit+" / min"))
  7249. w[axis + "homefinalvelunits"].set_text(_(unit+" / min"))
  7250. w[axis + "minfollowunits"].set_text(unit)
  7251. w[axis + "maxfollowunits"].set_text(unit)
  7252. if resolver:
  7253. w[axis + "encoderscale_label"].set_text(_("Resolver Scale:"))
  7254. if axis == 's':
  7255. #w["motor_screwunits"].set_text((""))
  7256. #w["encoder_screwunits"].set_text((""))
  7257. w.smaxoutput.set_sensitive(False)
  7258. w.sencodercounts.set_sensitive(encoder)
  7259. w.ssingleinputencoder.set_sensitive(encoder)
  7260. w["sinvertencoder"].set_sensitive(encoder)
  7261. w["ssingleinputencoder"].show()
  7262. w["saxistest"].set_sensitive(pwmgen or spindlepot)
  7263. w["sstepper_info"].set_sensitive(stepdriven)
  7264. w["smaxferror"].set_sensitive(False)
  7265. w["sminferror"].set_sensitive(False)
  7266. w["smaxvel"].set_sensitive(stepdriven)
  7267. w["smaxacc"].set_sensitive(stepdriven)
  7268. w["satspeedframe"].hide()
  7269. w["sfiltergainframe"].hide()
  7270. if not digital_at_speed and encoder:
  7271. w["satspeedframe"].show()
  7272. if encoder or resolver:
  7273. if (self.data.pyvcp and self.data.pyvcphaltype == 1 and self.data.pyvcpconnect == 1) or (self.data.gladevcp
  7274. and self.data.spindlespeedbar):
  7275. w["sfiltergainframe"].show()
  7276. set_active("useatspeed")
  7277. w["snearscale"].set_value(d["snearscale"]*100)
  7278. w["srpmrange"].set_value(d["srpmrange"])
  7279. set_value("filtergain")
  7280. set_active("singleinputencoder")
  7281. else:
  7282. w[axis+"maxferror"].set_sensitive(True)
  7283. w[axis+"minferror"].set_sensitive(True)
  7284. set_value("maxferror")
  7285. set_value("minferror")
  7286. set_text("compfilename")
  7287. set_active("comptype")
  7288. set_active("usebacklash")
  7289. set_value("backlash")
  7290. set_active("usecomp")
  7291. set_text("homepos")
  7292. set_text("minlim")
  7293. set_text("maxlim")
  7294. set_text("homesw")
  7295. w[axis+"homesearchvel"].set_text("%d" % (d[axis+"homesearchvel"]*60))
  7296. w[axis+"homelatchvel"].set_text("%d" % (d[axis+"homelatchvel"]*60))
  7297. w[axis+"homefinalvel"].set_text("%d" % (d[axis+"homefinalvel"]*60))
  7298. set_active("searchdir")
  7299. set_active("latchdir")
  7300. set_active("usehomeindex")
  7301. thisaxishome = set(("all-home", "home-" + axis, "min-home-" + axis,"max-home-" + axis, "both-home-" + axis))
  7302. homes = False
  7303. for i in thisaxishome:
  7304. test = self.data.findsignal(i)
  7305. if test: homes = True
  7306. w[axis + "homesw"].set_sensitive(homes)
  7307. w[axis + "homesearchvel"].set_sensitive(homes)
  7308. w[axis + "searchdir"].set_sensitive(homes)
  7309. w[axis + "latchdir"].set_sensitive(homes)
  7310. w[axis + "usehomeindex"].set_sensitive(encoder and homes)
  7311. w[axis + "homefinalvel"].set_sensitive(homes)
  7312. w[axis + "homelatchvel"].set_sensitive(homes)
  7313. i = d[axis + "usecomp"]
  7314. w[axis + "comptype"].set_sensitive(i)
  7315. w[axis + "compfilename"].set_sensitive(i)
  7316. i = d[axis + "usebacklash"]
  7317. w[axis + "backlash"].set_sensitive(i)
  7318. self.widgets.druid1.set_buttons_sensitive(1,0,1,1)
  7319. self.motor_encoder_sanity_check(None,axis)
  7320. def on_xusecomp_toggled(self, *args): self.comp_toggle('x')
  7321. def on_yusecomp_toggled(self, *args): self.comp_toggle('y')
  7322. def on_zusecomp_toggled(self, *args): self.comp_toggle('z')
  7323. def on_ausecomp_toggled(self, *args): self.comp_toggle('a')
  7324. def on_xusebacklash_toggled(self, *args): self.backlash_toggle('x')
  7325. def on_yusebacklash_toggled(self, *args): self.backlash_toggle('y')
  7326. def on_zusebacklash_toggled(self, *args): self.backlash_toggle('z')
  7327. def on_ausebacklash_toggled(self, *args): self.backlash_toggle('a')
  7328. def on_xdrivertype_changed(self, *args): self.driver_changed('x')
  7329. def on_ydrivertype_changed(self, *args): self.driver_changed('y')
  7330. def on_zdrivertype_changed(self, *args): self.driver_changed('z')
  7331. def on_adrivertype_changed(self, *args): self.driver_changed('a')
  7332. def on_sdrivertype_changed(self, *args): self.driver_changed('s')
  7333. def on_xbldc_toggled(self, *args): self.bldc_toggled('x')
  7334. def on_ybldc_toggled(self, *args): self.bldc_toggled('y')
  7335. def on_zbldc_toggled(self, *args): self.bldc_toggled('z')
  7336. def on_abldc_toggled(self, *args): self.bldc_toggled('a')
  7337. def on_sbldc_toggled(self, *args): self.bldc_toggled('s')
  7338. def driver_changed(self, axis):
  7339. d = self.data
  7340. w = self.widgets
  7341. v = w[axis + "drivertype"].get_active()
  7342. if v < len(drivertypes):
  7343. d = drivertypes[v]
  7344. w[axis + "steptime"].set_value(d[2])
  7345. w[axis + "stepspace"].set_value(d[3])
  7346. w[axis + "dirhold"].set_value(d[4])
  7347. w[axis + "dirsetup"].set_value(d[5])
  7348. w[axis + "steptime"].set_sensitive(0)
  7349. w[axis + "stepspace"].set_sensitive(0)
  7350. w[axis + "dirhold"].set_sensitive(0)
  7351. w[axis + "dirsetup"].set_sensitive(0)
  7352. else:
  7353. w[axis + "steptime"].set_sensitive(1)
  7354. w[axis + "stepspace"].set_sensitive(1)
  7355. w[axis + "dirhold"].set_sensitive(1)
  7356. w[axis + "dirsetup"].set_sensitive(1)
  7357. def drivertype_toindex(self, axis, what=None):
  7358. if what is None: what = self.data[axis + "drivertype"]
  7359. for i, d in enumerate(drivertypes):
  7360. if d[0] == what: return i
  7361. return len(drivertypes)
  7362. def drivertype_toid(self, axis, what=None):
  7363. if not isinstance(what, int): what = self.drivertype_toindex(axis, what)
  7364. if what < len(drivertypes): return drivertypes[what][0]
  7365. return "custom"
  7366. def drivertype_fromindex(self, axis):
  7367. i = self.widgets[axis + "drivertype"].get_active()
  7368. if i < len(drivertypes): return drivertypes[i][1]
  7369. return _("Custom")
  7370. def comp_toggle(self, axis):
  7371. i = self.widgets[axis + "usecomp"].get_active()
  7372. self.widgets[axis + "compfilename"].set_sensitive(i)
  7373. self.widgets[axis + "comptype"].set_sensitive(i)
  7374. if i:
  7375. self.widgets[axis + "backlash"].set_sensitive(0)
  7376. self.widgets[axis + "usebacklash"].set_active(0)
  7377. def bldc_toggled(self, axis):
  7378. i = self.widgets[axis + "bldc_option"].get_active()
  7379. self.widgets[axis + "bldcoptionbox"].set_sensitive(i)
  7380. def bldc_update(self,Widgets,axis):
  7381. w = self.widgets
  7382. i = False
  7383. if w[axis+"bldc_incremental_feedback"].get_active():
  7384. i = True
  7385. w[axis+"bldc_pattern_in"].set_sensitive(i and w[axis+"bldc_use_hall"].get_active() )
  7386. w[axis+"bldc_inital_value"].set_sensitive(i and w[axis+"bldc_use_encoder"].get_active() and not w[axis+"bldc_use_hall"].get_active() )
  7387. w[axis+"bldc_use_hall"].set_sensitive(i)
  7388. w[axis+"bldc_use_encoder"].set_sensitive(i)
  7389. w[axis+"bldc_use_index"].set_sensitive(i)
  7390. w[axis+"bldc_fanuc_alignment"].set_sensitive(i)
  7391. i = False
  7392. if w[axis+"bldc_emulated_feedback"].get_active():
  7393. i = True
  7394. w[axis+"bldc_output_hall"].set_sensitive(i)
  7395. w[axis+"bldc_output_fanuc"].set_sensitive(i)
  7396. w[axis+"bldc_pattern_out"].set_sensitive(i and w[axis+"bldc_output_hall"].get_active() )
  7397. def backlash_toggle(self, axis):
  7398. i = self.widgets[axis + "usebacklash"].get_active()
  7399. self.widgets[axis + "backlash"].set_sensitive(i)
  7400. if i:
  7401. self.widgets[axis + "compfilename"].set_sensitive(0)
  7402. self.widgets[axis + "comptype"].set_sensitive(0)
  7403. self.widgets[axis + "usecomp"].set_active(0)
  7404. def axis_done(self, axis):
  7405. d = self.data
  7406. w = self.widgets
  7407. def get_text(n): d[axis + n] = get_value(w[axis + n])
  7408. def get_pagevalue(n): d[axis + n] = get_value(w[axis + n])
  7409. def get_active(n): d[axis + n] = w[axis + n].get_active()
  7410. stepdrive = self.data.findsignal(axis+"-stepgen-step")
  7411. encoder = self.data.findsignal(axis+"-encoder-a")
  7412. resolver = self.data.findsignal(axis+"-resolver")
  7413. get_pagevalue("P")
  7414. get_pagevalue("I")
  7415. get_pagevalue("D")
  7416. get_pagevalue("FF0")
  7417. get_pagevalue("FF1")
  7418. get_pagevalue("FF2")
  7419. get_pagevalue("bias")
  7420. get_pagevalue("deadband")
  7421. get_pagevalue("maxoutput")
  7422. get_pagevalue("steptime")
  7423. get_pagevalue("stepspace")
  7424. get_pagevalue("dirhold")
  7425. get_pagevalue("dirsetup")
  7426. get_pagevalue("outputscale")
  7427. get_pagevalue("outputminlimit")
  7428. get_pagevalue("outputmaxlimit")
  7429. get_pagevalue("3pwmscale")
  7430. get_pagevalue("3pwmdeadtime")
  7431. get_active("bldc_option")
  7432. get_active("bldc_reverse")
  7433. get_pagevalue("bldc_scale")
  7434. get_pagevalue("bldc_poles")
  7435. get_pagevalue("bldc_encoder_offset")
  7436. get_pagevalue("bldc_drive_offset")
  7437. get_pagevalue("bldc_pattern_out")
  7438. get_pagevalue("bldc_pattern_in")
  7439. get_pagevalue("bldc_lead_angle")
  7440. get_pagevalue("bldc_inital_value")
  7441. get_pagevalue("8i20maxcurrent")
  7442. get_active("bldc_no_feedback")
  7443. get_active("bldc_absolute_feedback")
  7444. get_active("bldc_incremental_feedback")
  7445. get_active("bldc_use_hall")
  7446. get_active("bldc_use_encoder" )
  7447. get_active("bldc_use_index")
  7448. get_active("bldc_fanuc_alignment")
  7449. get_active("bldc_digital_output")
  7450. get_active("bldc_six_outputs")
  7451. get_active("bldc_emulated_feedback")
  7452. get_active("bldc_output_hall")
  7453. get_active("bldc_output_fanuc")
  7454. get_active("bldc_force_trapz")
  7455. if w[axis + "bldc_option"].get_active():
  7456. self.configure_bldc(axis)
  7457. d[axis + "encodercounts"] = int(float(w["encoderline"].get_text())*4)
  7458. if stepdrive: get_pagevalue("stepscale")
  7459. if encoder: get_pagevalue("encoderscale")
  7460. if resolver: get_pagevalue("encoderscale")
  7461. get_active("invertmotor")
  7462. get_active("invertencoder")
  7463. d[axis + "steprev"] = int(get_value(w["steprev"]))
  7464. d[axis + "microstep"] = int(get_value(w["microstep"]))
  7465. d[axis + "motor_pulleydriver"] = int(get_value(w["motor_pulleydriver"]))
  7466. d[axis + "motor_pulleydriven"] = int(get_value(w["motor_pulleydriven"]))
  7467. d[axis + "encoder_pulleydriver"] = int(get_value(w["encoder_pulleydriver"]))
  7468. d[axis + "encoder_pulleydriven"] = int(get_value(w["encoder_pulleydriven"]))
  7469. d[axis + "motor_leadscrew_tpi"] = int(get_value(w["motor_leadscrew_tpi"]))
  7470. d[axis + "encoder_leadscrew_tpi"] = int(get_value(w["encoder_leadscrew_tpi"]))
  7471. d[axis + "motor_leadscrew"] = int(get_value(w["motor_leadscrew"]))
  7472. d[axis + "encoder_leadscrew"] = int(get_value(w["encoder_leadscrew"]))
  7473. d[axis + "maxvel"] = (get_value(w[axis + "maxvel"])/60)
  7474. get_text("maxacc")
  7475. d[axis + "drivertype"] = self.drivertype_toid(axis, w[axis + "drivertype"].get_active())
  7476. if not axis == "s":
  7477. get_pagevalue("maxferror")
  7478. get_pagevalue("minferror")
  7479. get_text("homepos")
  7480. get_text("minlim")
  7481. get_text("maxlim")
  7482. get_text("homesw")
  7483. d[axis + "homesearchvel"] = (get_value(w[axis + "homesearchvel"])/60)
  7484. d[axis + "homelatchvel"] = (get_value(w[axis + "homelatchvel"])/60)
  7485. d[axis + "homefinalvel"] = (get_value(w[axis + "homefinalvel"])/60)
  7486. get_active("searchdir")
  7487. get_active("latchdir")
  7488. get_active("usehomeindex")
  7489. d[axis + "compfilename"] = w[axis + "compfilename"].get_text()
  7490. get_active("comptype")
  7491. d[axis + "backlash"]= w[axis + "backlash"].get_value()
  7492. get_active("usecomp")
  7493. get_active("usebacklash")
  7494. else:
  7495. get_active("useatspeed")
  7496. get_pagevalue("nearscale")
  7497. d["snearscale"] = w["snearscale"].get_value()/100
  7498. d["srpmrange"] = w["srpmrange"].get_value()
  7499. get_pagevalue("filtergain")
  7500. get_active("singleinputencoder")
  7501. def configure_bldc(self,axis):
  7502. d = self.data
  7503. string = ""
  7504. # Inputs
  7505. if d[axis + "bldc_no_feedback"]: string = string + "n"
  7506. elif d[axis +"bldc_absolute_feedback"]: string = string + "a"
  7507. elif d[axis + "bldc_incremental_feedback"]:
  7508. if d[axis + "bldc_use_hall"]: string = string + "h"
  7509. if d[axis + "bldc_use_encoder" ]: string = string + "q"
  7510. if d[axis + "bldc_use_index"]: string = string + "i"
  7511. if d[axis + "bldc_fanuc_alignment"]: string = string + "f"
  7512. # Outputs
  7513. if d[axis + "bldc_digital_output"]: string = string + "B"
  7514. if d[axis + "bldc_six_outputs"]: string = string + "6"
  7515. if d[axis + "bldc_emulated_feedback"]:
  7516. if d[axis + "bldc_output_hall"]: string = string + "H"
  7517. if d[axis + "bldc_output_fanuc"]: string = string +"F"
  7518. if d[axis + "bldc_force_trapz"]: string = string + "T"
  7519. #print "axis ",axis,"bldc config ",string
  7520. d[axis+"bldc_config"] = string
  7521. def calculate_scale(self,axis):
  7522. def get(n): return get_value(self.widgets[n])
  7523. stepdrive = self.data.findsignal(axis+"-stepgen-step")
  7524. encoder = self.data.findsignal(axis+"-encoder-a")
  7525. resolver = self.data.findsignal(axis+"-resolver")
  7526. # temparally add signals
  7527. templist1 = ["encoderline","encoder_leadscrew","encoder_leadscrew_tpi","encoder_wormdriven","encoder_wormdriver","encoder_pulleydriven",
  7528. "encoder_pulleydriver","steprev","motor_leadscrew","motor_leadscrew_tpi","microstep","motor_wormdriven","motor_wormdriver",
  7529. "motor_pulleydriven","motor_pulleydriver"]
  7530. for i in templist1:
  7531. self.data[i] = self.widgets[i].connect("value-changed", self.update_scale_calculation,axis)
  7532. templist2 = [ "cbencoder_pitch","cbencoder_tpi","cbencoder_worm","cbencoder_pulley","cbmotor_pitch","cbmotor_tpi","cbmicrosteps",
  7533. "cbmotor_worm","cbmotor_pulley"]
  7534. for i in templist2:
  7535. self.data[i] = self.widgets[i].connect("toggled", self.update_scale_calculation,axis)
  7536. self.update_scale_calculation(self.widgets,axis)
  7537. self.widgets.scaledialog.set_title(_("Axis Scale Calculation"))
  7538. self.widgets.scaledialog.show_all()
  7539. result = self.widgets.scaledialog.run()
  7540. self.widgets.scaledialog.hide()
  7541. # remove signals
  7542. for i in templist1:
  7543. self.widgets[i].disconnect(self.data[i])
  7544. for i in templist2:
  7545. self.widgets[i].disconnect(self.data[i])
  7546. if not result: return
  7547. if encoder or resolver:
  7548. self.widgets[axis+"encoderscale"].set_value(get("calcencoder_scale"))
  7549. if stepdrive:
  7550. self.widgets[axis+"stepscale"].set_value(get("calcmotor_scale"))
  7551. def update_scale_calculation(self,widgets,axis):
  7552. w = self.widgets
  7553. d = self.data
  7554. def get(n): return get_value(w[n])
  7555. stepdrive = self.data.findsignal(axis+"-stepgen-step")
  7556. encoder = self.data.findsignal(axis+"-encoder-a")
  7557. resolver = self.data.findsignal(axis+"-resolver")
  7558. motor_pulley_ratio = encoder_pulley_ratio = 1
  7559. motor_worm_ratio = encoder_worm_ratio = 1
  7560. encoder_scale = motor_scale = 0
  7561. microstepfactor = motor_pitch = encoder_pitch = motor_steps = 1
  7562. if axis == "a": rotary_scale = 360
  7563. else: rotary_scale = 1
  7564. try:
  7565. if stepdrive:
  7566. # stepmotor scale
  7567. w["calcmotor_scale"].set_sensitive(True)
  7568. w["stepscaleframe"].set_sensitive(True)
  7569. if w["cbmotor_pulley"].get_active():
  7570. w["motor_pulleydriver"].set_sensitive(True)
  7571. w["motor_pulleydriven"].set_sensitive(True)
  7572. motor_pulley_ratio = (get("motor_pulleydriven") / get("motor_pulleydriver"))
  7573. else:
  7574. w["motor_pulleydriver"].set_sensitive(False)
  7575. w["motor_pulleydriven"].set_sensitive(False)
  7576. if w["cbmotor_worm"].get_active():
  7577. w["motor_wormdriver"].set_sensitive(True)
  7578. w["motor_wormdriven"].set_sensitive(True)
  7579. motor_worm_ratio = (get("motor_wormdriver") / get("motor_wormdriven"))
  7580. else:
  7581. w["motor_wormdriver"].set_sensitive(False)
  7582. w["motor_wormdriven"].set_sensitive(False)
  7583. if w["cbmicrosteps"].get_active():
  7584. w["microstep"].set_sensitive(True)
  7585. microstepfactor = get("microstep")
  7586. else:
  7587. w["microstep"].set_sensitive(False)
  7588. if w["cbmotor_pitch"].get_active():
  7589. w["motor_leadscrew"].set_sensitive(True)
  7590. w["cbmotor_tpi"].set_active(False)
  7591. if self.data.units == _METRIC:
  7592. motor_pitch = 1./ get("motor_leadscrew")
  7593. else:
  7594. motor_pitch = 1./ (get("motor_leadscrew")* .03937008)
  7595. else: w["motor_leadscrew"].set_sensitive(False)
  7596. if w["cbmotor_tpi"].get_active():
  7597. w["motor_leadscrew_tpi"].set_sensitive(True)
  7598. w["cbmotor_pitch"].set_active(False)
  7599. if self.data.units == _METRIC:
  7600. motor_pitch = (get("motor_leadscrew_tpi")* .03937008)
  7601. else:
  7602. motor_pitch = get("motor_leadscrew_tpi")
  7603. else: w["motor_leadscrew_tpi"].set_sensitive(False)
  7604. motor_steps = get("steprev")
  7605. motor_scale = (motor_steps * microstepfactor * motor_pulley_ratio * motor_worm_ratio * motor_pitch) / rotary_scale
  7606. w["calcmotor_scale"].set_text("%.4f" % motor_scale)
  7607. else:
  7608. w["calcmotor_scale"].set_sensitive(False)
  7609. w["stepscaleframe"].set_sensitive(False)
  7610. # encoder scale
  7611. if encoder or resolver:
  7612. w["calcencoder_scale"].set_sensitive(True)
  7613. w["encoderscaleframe"].set_sensitive(True)
  7614. if w["cbencoder_pulley"].get_active():
  7615. w["encoder_pulleydriver"].set_sensitive(True)
  7616. w["encoder_pulleydriven"].set_sensitive(True)
  7617. encoder_pulley_ratio = (get("encoder_pulleydriven") / get("encoder_pulleydriver"))
  7618. else:
  7619. w["encoder_pulleydriver"].set_sensitive(False)
  7620. w["encoder_pulleydriven"].set_sensitive(False)
  7621. if w["cbencoder_worm"].get_active():
  7622. w["encoder_wormdriver"].set_sensitive(True)
  7623. w["encoder_wormdriven"].set_sensitive(True)
  7624. encoder_worm_ratio = (get("encoder_wormdriver") / get("encoder_wormdriven"))
  7625. else:
  7626. w["encoder_wormdriver"].set_sensitive(False)
  7627. w["encoder_wormdriven"].set_sensitive(False)
  7628. if w["cbencoder_pitch"].get_active():
  7629. w["encoder_leadscrew"].set_sensitive(True)
  7630. w["cbencoder_tpi"].set_active(False)
  7631. if self.data.units == _METRIC:
  7632. encoder_pitch = 1./ get("encoder_leadscrew")
  7633. else:
  7634. encoder_pitch = 1./ (get("encoder_leadscrew")*.03937008)
  7635. else: w["encoder_leadscrew"].set_sensitive(False)
  7636. if w["cbencoder_tpi"].get_active():
  7637. w["encoder_leadscrew_tpi"].set_sensitive(True)
  7638. w["cbencoder_pitch"].set_active(False)
  7639. if self.data.units == _METRIC:
  7640. encoder_pitch = (get("encoder_leadscrew_tpi")*.03937008)
  7641. else:
  7642. encoder_pitch = get("encoder_leadscrew_tpi")
  7643. else: w["encoder_leadscrew_tpi"].set_sensitive(False)
  7644. encoder_cpr = get_value(w[("encoderline")]) * 4
  7645. encoder_scale = (encoder_pulley_ratio * encoder_worm_ratio * encoder_pitch * encoder_cpr) / rotary_scale
  7646. w["calcencoder_scale"].set_text("%.4f" % encoder_scale)
  7647. else:
  7648. w["calcencoder_scale"].set_sensitive(False)
  7649. w["encoderscaleframe"].set_sensitive(False)
  7650. #new stuff
  7651. if stepdrive: scale = motor_scale
  7652. else: scale = encoder_scale
  7653. maxvps = (get_value(w[axis+"maxvel"]))/60
  7654. pps = (scale * (maxvps))/1000
  7655. if pps == 0: raise ValueError
  7656. pps = abs(pps)
  7657. w["khz"].set_text("%.1f" % pps)
  7658. acctime = (maxvps) / get_value(w[axis+"maxacc"])
  7659. accdist = acctime * .5 * (maxvps)
  7660. if encoder or resolver:
  7661. maxrpm = int(maxvps * 60 * (scale/encoder_cpr))
  7662. else:
  7663. maxrpm = int(maxvps * 60 * (scale/(microstepfactor * motor_steps)))
  7664. w["acctime"].set_text("%.4f" % acctime)
  7665. w["accdist"].set_text("%.4f" % accdist)
  7666. w["chartresolution"].set_text("%.7f" % (1.0 / scale))
  7667. w["calscale"].set_text(str(scale))
  7668. w["maxrpm"].set_text("%d" % maxrpm)
  7669. except (ValueError, ZeroDivisionError):
  7670. w["calcmotor_scale"].set_text("200")
  7671. w["calcencoder_scale"].set_text("1000")
  7672. w["chartresolution"].set_text("")
  7673. w["acctime"].set_text("")
  7674. if not axis == 's':
  7675. w["accdist"].set_text("")
  7676. w["khz"].set_text("")
  7677. w["calscale"].set_text("")
  7678. def motor_encoder_sanity_check(self,widgets,axis):
  7679. stepdrive = encoder = bad = resolver = pot = False
  7680. if self.data.findsignal(axis+"-stepgen-step"): stepdrive = True
  7681. if self.data.findsignal(axis+"-encoder-a"): encoder = True
  7682. if self.data.findsignal(axis+"-resolver"): resolver = True
  7683. if self.data.findsignal(axis+"-pot-outpot"): pot = True
  7684. if encoder or resolver:
  7685. if self.widgets[axis+"encoderscale"].get_value() < 1: bad = True
  7686. if stepdrive:
  7687. if self.widgets[axis+"stepscale"].get_value() < 1: bad = True
  7688. if not (encoder or resolver) and not stepdrive and not axis == "s": bad = True
  7689. if self.widgets[axis+"maxvel"] < 1: bad = True
  7690. if self.widgets[axis+"maxacc"] < 1: bad = True
  7691. if bad:
  7692. self.widgets.druid1.set_buttons_sensitive(1,0,1,1)
  7693. self.widgets[axis + "axistune"].set_sensitive(0)
  7694. self.widgets[axis + "axistest"].set_sensitive(0)
  7695. else:
  7696. self.widgets.druid1.set_buttons_sensitive(1,1,1,1)
  7697. self.widgets[axis + "axistune"].set_sensitive(1)
  7698. self.widgets[axis + "axistest"].set_sensitive(1)
  7699. def on_xaxis_prepare(self, *args): self.axis_prepare('x')
  7700. def on_yaxis_prepare(self, *args): self.axis_prepare('y')
  7701. def on_zaxis_prepare(self, *args): self.axis_prepare('z')
  7702. def on_aaxis_prepare(self, *args): self.axis_prepare('a')
  7703. def on_xaxis_next(self, *args):
  7704. self.axis_done('x')
  7705. if self.data.axes == 2:
  7706. self.widgets.druid1.set_page(self.widgets.zaxismotor)
  7707. return True
  7708. else:
  7709. self.widgets.druid1.set_page(self.widgets.yaxismotor)
  7710. return True
  7711. def on_yaxis_next(self, *args):
  7712. self.axis_done('y')
  7713. self.widgets.druid1.set_page(self.widgets.zaxismotor)
  7714. return True
  7715. def on_xaxis_back(self, *args):
  7716. self.axis_done('x')
  7717. self.widgets.druid1.set_page(self.widgets.xaxismotor)
  7718. return True
  7719. def on_yaxis_back(self, *args):
  7720. self.axis_done('y')
  7721. self.widgets.druid1.set_page(self.widgets.yaxismotor)
  7722. return True
  7723. def on_zaxis_next(self, *args):
  7724. self.axis_done('z')
  7725. if self.data.axes != 1 :
  7726. if self.has_spindle_speed_control():
  7727. self.widgets.druid1.set_page(self.widgets.saxismotor)
  7728. return True
  7729. else:
  7730. self.widgets.druid1.set_page(self.widgets.advanced)
  7731. return True
  7732. else:
  7733. self.widgets.druid1.set_page(self.widgets.aaxismotor)
  7734. return True
  7735. def on_zaxis_back(self, *args):
  7736. self.axis_done('z')
  7737. self.widgets.druid1.set_page(self.widgets.zaxismotor)
  7738. return True
  7739. def on_aaxis_next(self, *args):
  7740. self.axis_done('a')
  7741. if self.has_spindle_speed_control():
  7742. self.widgets.druid1.set_page(self.widgets.saxismotor)
  7743. else:
  7744. self.widgets.druid1.set_page(self.widgets.advanced)
  7745. return True
  7746. def on_aaxis_back(self, *args):
  7747. self.axis_done('a')
  7748. self.widgets.druid1.set_page(self.widgets.aaxismotor)
  7749. return True
  7750. def on_xaxistest_clicked(self, *args): self.test_axis('x')
  7751. def on_yaxistest_clicked(self, *args): self.test_axis('y')
  7752. def on_zaxistest_clicked(self, *args): self.test_axis('z')
  7753. def on_aaxistest_clicked(self, *args): self.test_axis('a')
  7754. def on_saxistest_clicked(self, *args): self.test_axis('s')
  7755. def on_xaxistune_clicked(self, *args): self.tune_axis('x')
  7756. def on_yaxistune_clicked(self, *args): self.tune_axis('y')
  7757. def on_zaxistune_clicked(self, *args): self.tune_axis('z')
  7758. def on_aaxistune_clicked(self, *args): self.tune_axis('a')
  7759. def on_saxistune_clicked(self, *args): self.tune_axis('s')
  7760. def on_saxismotor_prepare(self, *args):
  7761. self.data.help = "help-axismotor.txt"
  7762. self.axis_prepare('s')
  7763. def on_saxismotor_next(self, *args):
  7764. self.axis_done('s')
  7765. self.widgets.druid1.set_page(self.widgets.advanced)
  7766. return True
  7767. def on_saxismotor_back(self, *args):
  7768. self.axis_done('s')
  7769. if self.data.axes != 1:
  7770. self.widgets.druid1.set_page(self.widgets.zaxis)
  7771. else:
  7772. self.widgets.druid1.set_page(self.widgets.aaxis)
  7773. return True
  7774. def has_spindle_speed_control(self):
  7775. for test in ("s-stepgen-step", "s-pwm-pulse", "s-encoder-a", "spindle-on", "spindle-cw", "spindle-ccw", "spindle-brake",
  7776. "s-pot-output"):
  7777. has_spindle = self.data.findsignal(test)
  7778. if has_spindle:
  7779. return True
  7780. return False
  7781. def on_advanced_prepare(self, *args):
  7782. self.data.help = "help-advanced.txt"
  7783. self.widgets.classicladder.set_active(self.data.classicladder)
  7784. self.widgets.modbus.set_active(self.data.modbus)
  7785. self.widgets.digitsin.set_value(self.data.digitsin)
  7786. self.widgets.digitsout.set_value(self.data.digitsout)
  7787. self.widgets.s32in.set_value(self.data.s32in)
  7788. self.widgets.s32out.set_value(self.data.s32out)
  7789. self.widgets.floatsin.set_value(self.data.floatsin)
  7790. self.widgets.floatsout.set_value(self.data.floatsout)
  7791. self.widgets.halui.set_active(self.data.halui)
  7792. self.widgets.ladderexist.set_active(self.data.ladderexist)
  7793. self.widgets.laddertouchz.set_active(self.data.laddertouchz)
  7794. self.on_halui_toggled()
  7795. for i in range(0,15):
  7796. self.widgets["halui_cmd"+str(i)].set_text(self.data["halui_cmd"+str(i)])
  7797. self.widgets.ladderconnect.set_active(self.data.ladderconnect)
  7798. self.on_classicladder_toggled()
  7799. def on_advanced_next(self, *args):
  7800. self.data.classicladder = self.widgets.classicladder.get_active()
  7801. self.data.modbus = self.widgets.modbus.get_active()
  7802. self.data.digitsin = self.widgets.digitsin.get_value()
  7803. self.data.digitsout = self.widgets.digitsout.get_value()
  7804. self.data.s32in = self.widgets.s32in.get_value()
  7805. self.data.s32out = self.widgets.s32out.get_value()
  7806. self.data.floatsin = self.widgets.floatsin.get_value()
  7807. self.data.floatsout = self.widgets.floatsout.get_value()
  7808. self.data.halui = self.widgets.halui.get_active()
  7809. self.data.ladderexist = self.widgets.ladderexist.get_active()
  7810. self.data.laddertouchz = self.widgets.laddertouchz.get_active()
  7811. for i in range(0,15):
  7812. self.data["halui_cmd"+str(i)] = self.widgets["halui_cmd"+str(i)].get_text()
  7813. self.data.ladderconnect = self.widgets.ladderconnect.get_active()
  7814. if self.data.classicladder:
  7815. if self.widgets.ladderblank.get_active() == True:
  7816. if self.data.tempexists:
  7817. self.data.laddername='TEMP.clp'
  7818. else:
  7819. self.data.laddername= 'blank.clp'
  7820. self.data.ladderhaltype = 0
  7821. if self.widgets.ladder1.get_active() == True:
  7822. self.data.laddername = 'estop.clp'
  7823. has_estop = self.data.findsignal("estop-ext")
  7824. if not has_estop:
  7825. self.warning_dialog(_("You need to designate an E-stop input pin for this ladder program."),True)
  7826. self.widgets.druid1.set_page(self.widgets.advanced)
  7827. return True
  7828. self.data.ladderhaltype = 1
  7829. if self.widgets.ladder2.get_active() == True:
  7830. self.data.laddername = 'serialmodbus.clp'
  7831. self.data.modbus = 1
  7832. self.widgets.modbus.set_active(self.data.modbus)
  7833. self.data.ladderhaltype = 0
  7834. if self.widgets.laddertouchz.get_active() == True:
  7835. has_probe = self.data.findsignal("probe-in")
  7836. if not has_probe:
  7837. self.warning_dialog(_("You need to designate a probe input pin for this ladder program."),True)
  7838. self.widgets.druid1.set_page(self.widgets.advanced)
  7839. return True
  7840. self.data.ladderhaltype = 2
  7841. self.data.laddername = 'touchoff_z.clp'
  7842. self.data.halui = True
  7843. self.widgets.halui.set_active(True)
  7844. if self.widgets.ladderexist.get_active() == True:
  7845. self.data.laddername='custom.clp'
  7846. else:
  7847. if os.path.exists(os.path.expanduser("~/linuxcnc/configs/%s/custom.clp" % self.data.machinename)):
  7848. if not self.warning_dialog(_("OK to replace existing custom ladder program?\nExisting\
  7849. Custom.clp will be renamed custom_backup.clp.\nAny existing file named -custom_backup.clp- will be lost.\
  7850. Selecting 'existing ladder program' will avoid this warning"),False):
  7851. self.widgets.druid1.set_page(self.widgets.advanced)
  7852. return True
  7853. if self.widgets.ladderexist.get_active() == False:
  7854. if os.path.exists(os.path.join(distdir, "configurable_options/ladder/TEMP.clp")):
  7855. if not self.warning_dialog(_("You edited a ladder program and have selected a \
  7856. different program to copy to your configuration file.\nThe edited program will be lost.\n\nAre you sure? "),False):
  7857. self.widgets.druid1.set_page(self.widgets.advanced)
  7858. return True
  7859. def on_advanced_back(self, *args):
  7860. if self.has_spindle_speed_control():
  7861. self.widgets.druid1.set_page(self.widgets.saxismotor)
  7862. elif self.data.axes != 1:
  7863. self.widgets.druid1.set_page(self.widgets.zaxis)
  7864. else:
  7865. self.widgets.druid1.set_page(self.widgets.aaxis)
  7866. return True
  7867. def on_loadladder_clicked(self, *args):self.load_ladder(self)
  7868. def on_halui_toggled(self, *args):
  7869. i= self.widgets.halui.get_active()
  7870. self.widgets.haluitable.set_sensitive(i)
  7871. def on_classicladder_toggled(self, *args):
  7872. i= self.widgets.classicladder.get_active()
  7873. self.widgets.digitsin.set_sensitive(i)
  7874. self.widgets.digitsout.set_sensitive(i)
  7875. self.widgets.s32in.set_sensitive(i)
  7876. self.widgets.s32out.set_sensitive(i)
  7877. self.widgets.floatsin.set_sensitive(i)
  7878. self.widgets.floatsout.set_sensitive(i)
  7879. self.widgets.modbus.set_sensitive(i)
  7880. self.widgets.ladderblank.set_sensitive(i)
  7881. self.widgets.ladder1.set_sensitive(i)
  7882. self.widgets.ladder2.set_sensitive(i)
  7883. self.widgets.laddertouchz.set_sensitive(i)
  7884. if self.widgets.createconfig.get_active():
  7885. self.widgets.ladderexist.set_sensitive(False)
  7886. else:
  7887. self.widgets.ladderexist.set_sensitive(i)
  7888. self.widgets.loadladder.set_sensitive(i)
  7889. self.widgets.label_digin.set_sensitive(i)
  7890. self.widgets.label_digout.set_sensitive(i)
  7891. self.widgets.label_s32in.set_sensitive(i)
  7892. self.widgets.label_s32out.set_sensitive(i)
  7893. self.widgets.label_floatin.set_sensitive(i)
  7894. self.widgets.label_floatout.set_sensitive(i)
  7895. self.widgets.ladderconnect.set_sensitive(i)
  7896. if self.widgets.laddertouchz.get_active():
  7897. i = self.data.gladevcphaluicmds
  7898. self.widgets["halui_cmd%d"%(i)].set_text("G38.2 Z-2 F16 ( search for touch off plate )")
  7899. self.widgets["halui_cmd%d"%(i+1)].set_text("G10 L20 P0 Z.25 ( Ofset current Origin by plate thickness )")
  7900. self.widgets["halui_cmd%d"%(i+2)].set_text("G0 Z.5 ( Rapid away from touch off plate )")
  7901. def on_pyvcp_toggled(self,*args):
  7902. i= self.widgets.pyvcp.get_active()
  7903. self.widgets.pyvcpblank.set_sensitive(i)
  7904. self.widgets.pyvcp1.set_sensitive(i)
  7905. self.widgets.pyvcp2.set_sensitive(i)
  7906. self.widgets.pyvcpgeometry.set_sensitive(i)
  7907. if self.widgets.createconfig.get_active():
  7908. self.widgets.pyvcpexist.set_sensitive(False)
  7909. else:
  7910. self.widgets.pyvcpexist.set_sensitive(i)
  7911. self.widgets.displaypanel.set_sensitive(i)
  7912. self.widgets.pyvcpconnect.set_sensitive(i)
  7913. def on_displaypanel_clicked(self,*args):
  7914. self.testpanel(self)
  7915. def on_realtime_components_prepare(self,*args):
  7916. self.data.help = "help-realtime.txt"
  7917. self.widgets.userneededpid.set_value(self.data.userneededpid)
  7918. self.widgets.userneededabs.set_value(self.data.userneededabs)
  7919. self.widgets.userneededscale.set_value(self.data.userneededscale)
  7920. self.widgets.userneededmux16.set_value(self.data.userneededmux16)
  7921. self.widgets.userneededlowpass.set_value(self.data.userneededlowpass)
  7922. if not self.data._components_is_prepared:
  7923. textbuffer = self.widgets.loadcompservo.get_buffer()
  7924. for i in self.data.loadcompservo:
  7925. if i == '': continue
  7926. textbuffer.insert_at_cursor(i+"\n" )
  7927. textbuffer = self.widgets.addcompservo.get_buffer()
  7928. for i in self.data.addcompservo:
  7929. if i == '': continue
  7930. textbuffer.insert_at_cursor(i+"\n" )
  7931. textbuffer = self.widgets.loadcompbase.get_buffer()
  7932. for i in self.data.loadcompbase:
  7933. if i == '': continue
  7934. textbuffer.insert_at_cursor(i+"\n" )
  7935. textbuffer = self.widgets.addcompbase.get_buffer()
  7936. for i in self.data.addcompbase:
  7937. if i == '': continue
  7938. textbuffer.insert_at_cursor(i+"\n" )
  7939. self.data._components_is_prepared = True
  7940. def on_realtime_components_next(self,*args):
  7941. self.data.userneededpid = int(self.widgets.userneededpid.get_value())
  7942. self.data.userneededabs = int(self.widgets.userneededabs.get_value())
  7943. self.data.userneededscale = int(self.widgets.userneededscale.get_value())
  7944. self.data.userneededmux16 = int(self.widgets.userneededmux16.get_value())
  7945. self.data.userneededlowpass = int(self.widgets.userneededlowpass.get_value())
  7946. textbuffer = self.widgets.loadcompservo.get_buffer()
  7947. startiter = textbuffer.get_start_iter()
  7948. enditer = textbuffer.get_end_iter()
  7949. test = textbuffer.get_text(startiter,enditer)
  7950. i = test.split('\n')
  7951. self.data.loadcompservo = i
  7952. textbuffer = self.widgets.addcompservo.get_buffer()
  7953. startiter = textbuffer.get_start_iter()
  7954. enditer = textbuffer.get_end_iter()
  7955. test = textbuffer.get_text(startiter,enditer)
  7956. i = test.split('\n')
  7957. self.data.addcompservo = i
  7958. textbuffer = self.widgets.loadcompbase.get_buffer()
  7959. startiter = textbuffer.get_start_iter()
  7960. enditer = textbuffer.get_end_iter()
  7961. test = textbuffer.get_text(startiter,enditer)
  7962. i = test.split('\n')
  7963. self.data.loadcompbase = i
  7964. textbuffer = self.widgets.addcompbase.get_buffer()
  7965. startiter = textbuffer.get_start_iter()
  7966. enditer = textbuffer.get_end_iter()
  7967. test = textbuffer.get_text(startiter,enditer)
  7968. i = test.split('\n')
  7969. self.data.addcompbase = i
  7970. def on_complete_finish(self, *args):
  7971. # if parallel ports not used clear all signals
  7972. parportnames = ("pp1","pp2","pp3")
  7973. for check,connector in enumerate(parportnames):
  7974. if self.data.number_pports >= (check+1):continue
  7975. # initialize parport input / inv pins
  7976. for i in (1,2,3,4,5,6,7,8,10,11,12,13,15):
  7977. pinname ="%sIpin%d"% (connector,i)
  7978. self.data[pinname] = UNUSED_INPUT
  7979. pinname ="%sIpin%dinv"% (connector,i)
  7980. self.data[pinname] = False
  7981. # initialize parport output / inv pins
  7982. for i in (1,2,3,4,5,6,7,8,9,14,16,17):
  7983. pinname ="%sOpin%d"% (connector,i)
  7984. self.data[pinname] = UNUSED_OUTPUT
  7985. pinname ="%sOpin%dinv"% (connector,i)
  7986. self.data[pinname] = False
  7987. # clear all unused mesa signals
  7988. for boardnum in(0,1):
  7989. for connector in(2,3,4,5,6,7,8,9):
  7990. if self.data.number_mesa >= boardnum + 1 :
  7991. if connector in(self.data["mesa%d_currentfirmwaredata"% (boardnum)][_NUMOFCNCTRS]) :
  7992. continue
  7993. # This initializes GPIO input pins
  7994. for i in range(0,16):
  7995. pinname ="mesa%dc%dpin%d"% (boardnum,connector,i)
  7996. self.data[pinname] = UNUSED_INPUT
  7997. pinname ="mesa%dc%dpin%dtype"% (boardnum,connector,i)
  7998. self.data[pinname] = GPIOI
  7999. # This initializes GPIO output pins
  8000. for i in range(16,24):
  8001. pinname ="mesa%dc%dpin%d"% (boardnum,connector,i)
  8002. self.data[pinname] = UNUSED_OUTPUT
  8003. pinname ="mesa%dc%dpin%dtype"% (boardnum,connector,i)
  8004. self.data[pinname] = GPIOO
  8005. # This initializes the mesa inverse pins
  8006. for i in range(0,24):
  8007. pinname ="mesa%dc%dpin%dinv"% (boardnum,connector,i)
  8008. self.data[pinname] = False
  8009. # clear unused sserial signals
  8010. keeplist =[]
  8011. # if the current firmware supports sserial better check for used channels
  8012. # and make a 'keeplist'. we don't want to clear them
  8013. if self.data["mesa%d_currentfirmwaredata"% boardnum][_MAXSSERIALPORTS]:
  8014. #search all pins for sserial port
  8015. for concount,connector in enumerate(self.data["mesa%d_currentfirmwaredata"% boardnum][_NUMOFCNCTRS]) :
  8016. for pin in range (0,24):
  8017. firmptype,compnum = self.data["mesa%d_currentfirmwaredata"% boardnum][_STARTOFDATA+pin+(concount*24)]
  8018. p = 'mesa%dc%dpin%d' % (boardnum, connector, pin)
  8019. ptype = 'mesa%dc%dpin%dtype' % (boardnum, connector , pin)
  8020. if self.data[ptype] in (TXDATA0,TXDATA1,TXDATA2,TXDATA3,TXDATA4,SS7I76M0,SS7I76M2,SS7I76M3,
  8021. SS7I77M0,SS7I77M1,SS7I77M3,SS7I77M4) and not self.data[p] == UNUSED_SSERIAL:
  8022. if self.data[ptype] in (TXDATA0,SS7I76M0,SS7I77M0): channelnum = 0
  8023. elif self.data[ptype] in (TXDATA1,SS7I77M1): channelnum = 1
  8024. elif self.data[ptype] == TXDATA2: channelnum = 2
  8025. elif self.data[ptype] in (TXDATA3,SS7I76M3,SS7I77M3): channelnum = 3
  8026. elif self.data[ptype] in (TXDATA4,SS7I77M4): channelnum = 4
  8027. keeplist.append(channelnum)
  8028. #print "board # %d sserial keeplist"%(boardnum),keeplist
  8029. # ok clear the sserial pins unless they are in the keeplist
  8030. port = 0# TODO hard code at only 1 sserial port
  8031. for channel in range(0,5): #TODO hardcoded at 5 sserial channels instead of 8
  8032. if channel in keeplist: continue
  8033. # This initializes pins
  8034. for i in range(0,_SSCOMBOLEN):
  8035. pinname ="mesa%dsserial%d_%dpin%d"% (boardnum, port,channel,i)
  8036. if i < 24:
  8037. self.data[pinname] = UNUSED_INPUT
  8038. else:
  8039. self.data[pinname] = UNUSED_OUTPUT
  8040. pinname ="mesa%dsserial%d_%dpin%dtype"% (boardnum, port,channel,i)
  8041. if i < 24:
  8042. self.data[pinname] = GPIOI
  8043. else:
  8044. self.data[pinname] = GPIOO
  8045. pinname ="mesa%dsserial%d_%dpin%dinv"% (boardnum, port,channel,i)
  8046. self.data[pinname] = False
  8047. self.data.save()
  8048. if not self.warning_dialog (_("Do you wish to continue to edit this configuration."),False):
  8049. gtk.main_quit()
  8050. #self._mesa0_configured = False
  8051. #self._mesa1_configured = False
  8052. self.data._re_editmode = True
  8053. self.widgets.druid1.set_page(self.widgets.basicinfo)
  8054. def on_calculate_ideal_period(self, *args):
  8055. steptime = self.widgets.steptime.get_value()
  8056. stepspace = self.widgets.stepspace.get_value()
  8057. latency = self.widgets.latency.get_value()
  8058. minperiod = self.data.minperiod(steptime, stepspace, latency)
  8059. maxhz = int(1e9 / minperiod)
  8060. self.widgets.baseperiod.set_text("%d ns" % minperiod)
  8061. self.widgets.maxsteprate.set_text("%d Hz" % maxhz)
  8062. def on_latency_test_clicked(self, w):
  8063. self.latency_pid = os.spawnvp(os.P_NOWAIT,
  8064. "latency-test", ["latency-test"])
  8065. self.widgets['window1'].set_sensitive(0)
  8066. gobject.timeout_add(1, self.latency_running_callback)
  8067. def latency_running_callback(self):
  8068. pid, status = os.waitpid(self.latency_pid, os.WNOHANG)
  8069. if pid:
  8070. self.widgets['window1'].set_sensitive(1)
  8071. return False
  8072. return True
  8073. def on_address_search_clicked(self,w):
  8074. self.on_druid1_help()
  8075. match = os.popen('lspci -v').read()
  8076. textbuffer = self.widgets.textoutput.get_buffer()
  8077. try :
  8078. textbuffer.set_text(match)
  8079. self.widgets.helpnotebook.set_current_page(2)
  8080. self.widgets.helpwindow.show_all()
  8081. except:
  8082. text = _("PCI search page is unavailable\n")
  8083. self.warning_dialog(text,True)
  8084. def parporttest(self,w):
  8085. if not self.check_for_rt(self):
  8086. return
  8087. panelname = os.path.join(distdir, "configurable_options/pyvcp")
  8088. self.halrun = halrun = os.popen("cd %(panelname)s\nhalrun -I > /dev/null"% {'panelname':panelname,}, "w" )
  8089. halrun.write("loadrt threads period1=100000 name1=fast fp1=0 period2=%d name2=slow\n"% self.data.servoperiod)
  8090. self.hal_cmnds("LOAD")
  8091. for i in range(0,self.data.number_pports ):
  8092. halrun.write("loadusr -Wn parport%(number)dtest pyvcp -g +%(pos)d+0 -c parport%(number)dtest %(panel)s\n"
  8093. % {'pos':(i*300),'number':i,'panel':"parportpanel.xml\n",})
  8094. halrun.write("loadrt or2 count=%d\n"%(self.data.number_pports * 12))
  8095. self.hal_cmnds("READ")
  8096. for i in range(0,(self.data.number_pports * 12)):
  8097. halrun.write("addf or2.%d fast\n"% i)
  8098. halrun.write("loadusr halmeter pin parport.0.pin-01-out -g 0 500\n")
  8099. self.hal_cmnds("WRITE")
  8100. templist = ("pp1","pp2","pp3")
  8101. for j in range(self.data.number_pports):
  8102. if self.data[templist[j]+"_direction"] == 1:
  8103. inputpins = (10,11,12,13,15)
  8104. outputpins = (1,2,3,4,5,6,7,8,9,14,16,17)
  8105. for x in (2,3,4,5,6,7,8,9):
  8106. halrun.write( "setp parport%dtest.led.%d.disable true\n"%(j, x))
  8107. halrun.write( "setp parport%dtest.led_text.%d.disable true\n"%(j, x))
  8108. else:
  8109. inputpins = (2,3,4,5,6,7,8,9,10,11,12,13,15)
  8110. outputpins = (1,14,16,17)
  8111. for x in (2,3,4,5,6,7,8,9):
  8112. halrun.write( "setp parport%dtest.button.%d.disable true\n"% (j , x))
  8113. halrun.write( "setp parport%dtest.button_text.%d.disable true\n"% (j , x))
  8114. for x in inputpins:
  8115. i = self.widgets["%sIpin%dinv" % (templist[j], x)].get_active()
  8116. if i: halrun.write( "net red_in_not.%d parport%dtest.led.%d <= parport.%d.pin-%02d-in-not\n" % (x, j, x, j, x))
  8117. else: halrun.write( "net red_in.%d parport%dtest.led.%d <= parport.%d.pin-%02d-in\n" % (x, j, x, j ,x))
  8118. for num, x in enumerate(outputpins):
  8119. i = self.widgets["%sOpin%dinv" % (templist[j], x)].get_active()
  8120. if i: halrun.write( "setp parport.%d.pin-%02d-out-invert true\n" %(j, x))
  8121. halrun.write("net signal_out%d or2.%d.out parport.%d.pin-%02d-out\n"% (x, num, j, x))
  8122. halrun.write("net pushbutton.%d or2.%d.in1 parport%dtest.button.%d\n"% (x, num, j, x))
  8123. halrun.write("net latchbutton.%d or2.%d.in0 parport%dtest.checkbutton.%d\n"% (x, num, j, x))
  8124. halrun.write("start\n")
  8125. halrun.write("waitusr parport0test\n"); halrun.flush()
  8126. halrun.close()
  8127. self.widgets['window1'].set_sensitive(1)
  8128. # This is for pyvcp test panel
  8129. def testpanel(self,w):
  8130. pos = "+0+0"
  8131. size = ""
  8132. panelname = os.path.join(distdir, "configurable_options/pyvcp")
  8133. if self.widgets.pyvcpblank.get_active() == True:
  8134. return True
  8135. if self.widgets.pyvcp1.get_active() == True:
  8136. panel = "spindle.xml"
  8137. if self.widgets.pyvcp2.get_active() == True:
  8138. panel = "xyzjog.xml"
  8139. if self.widgets.pyvcpexist.get_active() == True:
  8140. panel = "pyvcp-panel.xml"
  8141. panelname = os.path.expanduser("~/linuxcnc/configs/%s" % self.data.machinename)
  8142. if self.widgets.pyvcpposition.get_active() == True:
  8143. xpos = self.widgets.pyvcpxpos.get_value()
  8144. ypos = self.widgets.pyvcpypos.get_value()
  8145. pos = "+%d+%d"% (xpos,ypos)
  8146. if self.widgets.pyvcpsize.get_active() == True:
  8147. width = self.widgets.pyvcpwidth.get_value()
  8148. height = self.widgets.pyvcpheight.get_value()
  8149. size = "%dx%d"% (width,height)
  8150. self.halrun = halrun = os.popen("cd %(panelname)s\nhalrun -I > /dev/null"% {'panelname':panelname,}, "w" )
  8151. halrun.write("loadusr -Wn displaytest pyvcp -g %(size)s%(pos)s -c displaytest %(panel)s\n" %{'size':size,'pos':pos,'panel':panel,})
  8152. if self.widgets.pyvcp1.get_active() == True:
  8153. halrun.write("setp displaytest.spindle-speed 1000\n")
  8154. halrun.write("waitusr displaytest\n"); halrun.flush()
  8155. halrun.close()
  8156. def on_gladevcp_toggled(self,*args):
  8157. i = self.widgets.gladevcp.get_active()
  8158. self.widgets.gladevcpbox.set_sensitive( i )
  8159. if self.widgets.sideembededgvcp.get_active() and not self.data.frontend == _AXIS:
  8160. if self.data.frontend == _TOUCHY: self.widgets.centerembededgvcp.set_active(True)
  8161. else: self.widgets.standalonegvcp.set_active(True)
  8162. self.widgets.sideembededgvcp.set_sensitive(self.data.frontend == _AXIS)
  8163. self.widgets.centerembededgvcp.set_sensitive(self.data.frontend == _TOUCHY or self.data.frontend == _AXIS)
  8164. if self.widgets.centerembededgvcp.get_active() and not ( self.data.frontend == _AXIS or self.data.frontend == _TOUCHY ):
  8165. self.widgets.standalonegvcp.set_active(True)
  8166. i = self.widgets.standalonegvcp.get_active()
  8167. self.widgets.gladevcpsize.set_sensitive(i)
  8168. self.widgets.gladevcpposition.set_sensitive(i)
  8169. self.widgets.gladevcpforcemax.set_sensitive(i)
  8170. if not i:
  8171. self.widgets.gladevcpsize.set_active(False)
  8172. self.widgets.gladevcpposition.set_active(False)
  8173. self.widgets.gladevcpforcemax.set_active(False)
  8174. i = self.widgets.gladevcpsize.get_active()
  8175. self.widgets.gladevcpwidth.set_sensitive(i)
  8176. self.widgets.gladevcpheight.set_sensitive(i)
  8177. i = self.widgets.gladevcpposition.get_active()
  8178. self.widgets.gladevcpxpos.set_sensitive(i)
  8179. self.widgets.gladevcpypos.set_sensitive(i)
  8180. for i in (("zerox","x"),("zeroy","y"),("zeroz","z"),("zeroa","a"),("autotouchz","z")):
  8181. if not i[1] in(self.data.available_axes):
  8182. self.widgets[i[0]].set_active(False)
  8183. self.widgets[i[0]].set_sensitive(False)
  8184. else:
  8185. self.widgets[i[0]].set_sensitive(True)
  8186. def on_displaygladevcp_clicked(self,*args):
  8187. pos = "+0+0"
  8188. size = "200x200"
  8189. options = ""
  8190. folder = "/tmp"
  8191. if not self.widgets.createconfig.get_active() and self.widgets.gladeexists.get_active():
  8192. folder = os.path.expanduser("~/linuxcnc/configs/%s" % self.data.machinename)
  8193. if not os.path.exists(folder + "/gvcp-panel.ui"):
  8194. self.warning_dialog (_("""You specified there is an existing gladefile, \
  8195. But there is not one in the machine-named folder.."""),True)
  8196. return
  8197. self.gladevcptestpanel(self)
  8198. if self.widgets.gladevcpposition.get_active() == True:
  8199. xpos = self.widgets.gladevcpxpos.get_value()
  8200. ypos = self.widgets.gladevcpypos.get_value()
  8201. pos = "+%d+%d"% (xpos,ypos)
  8202. if self.widgets.gladevcpsize.get_active() == True:
  8203. width = self.widgets.gladevcpwidth.get_value()
  8204. height = self.widgets.gladevcpheight.get_value()
  8205. size = "%dx%d"% (width,height)
  8206. if not self.widgets.gladevcptheme.get_active_text() == "Follow System Theme":
  8207. options ="-t %s"% (self.widgets.gladevcptheme.get_active_text())
  8208. print options
  8209. self.halrun = halrun = os.popen("cd %s\nhalrun -I > /dev/null"%(folder), "w" )
  8210. halrun.write("loadusr -Wn displaytest gladevcp -g %(size)s%(pos)s -c displaytest %(option)s gvcp-panel.ui\n" %{'size':size,'pos':pos,'option':options})
  8211. if self.widgets.spindlespeedbar.get_active():
  8212. halrun.write("setp displaytest.spindle-speed 500\n")
  8213. if self.widgets.zerox.get_active():
  8214. halrun.write("setp displaytest.zero-x-active true\n")
  8215. if self.widgets.zeroy.get_active():
  8216. halrun.write("setp displaytest.zero-y-active true\n")
  8217. if self.widgets.zeroz.get_active():
  8218. halrun.write("setp displaytest.zero-z-active true\n")
  8219. if self.widgets.zeroa.get_active():
  8220. halrun.write("setp displaytest.zero-a-active true\n")
  8221. if self.widgets.autotouchz.get_active():
  8222. halrun.write("setp displaytest.auto-touch-z-active true\n")
  8223. if self.widgets.spindleatspeed.get_active():
  8224. halrun.write("setp displaytest.spindle-at-speed-led true\n")
  8225. halrun.write("setp displaytest.button-box-active true\n")
  8226. halrun.write("waitusr displaytest\n"); halrun.flush()
  8227. halrun.close()
  8228. def gladevcptestpanel(self,w):
  8229. directory = "/tmp/"
  8230. filename = os.path.join(directory, "gvcp-panel.ui")
  8231. file = open(filename, "w")
  8232. print >>file, ("""<?xml version="1.0"?>
  8233. <interface>
  8234. <!-- interface-requires gladevcp 0.0 -->
  8235. <requires lib="gtk+" version="2.16"/>
  8236. <!-- interface-naming-policy project-wide -->
  8237. <object class="GtkWindow" id="window1">
  8238. <property name="width_request">100</property>
  8239. <child>
  8240. <object class="GtkVBox" id="vbox1">
  8241. <property name="visible">True</property>""")
  8242. if self.widgets.spindlespeedbar.get_active():
  8243. print >>file, ("""
  8244. <child>
  8245. <object class="HAL_HBar" id="spindle-speed">
  8246. <property name="visible">True</property>
  8247. <property name="force_height">36</property>""")
  8248. print >>file, ("""<property name="max">%(maxrpm)d</property>"""%{'maxrpm':self.widgets.maxspeeddisplay.get_value() })
  8249. print >>file, ("""
  8250. <property name="z0_color">#0000ffff0000</property>
  8251. <property name="value">44.25</property>
  8252. <property name="z1_color">#ffffffff0000</property>
  8253. <property name="bg_color">#bebebebebebe</property>
  8254. <property name="text_template">Spindle: % 4d RPM</property>
  8255. <property name="z0_border">0.94999998807907104</property>
  8256. <property name="z2_color">#ffff00000000</property>
  8257. <property name="show_limits">False</property>
  8258. </object>
  8259. <packing>
  8260. <property name="expand">False</property>
  8261. <property name="position">0</property>
  8262. </packing>
  8263. </child>""" )
  8264. if self.widgets.spindleatspeed.get_active():
  8265. print >>file, ("""
  8266. <child>
  8267. <object class="GtkHBox" id="hbox1">
  8268. <property name="visible">True</property>
  8269. <child>
  8270. <object class="GtkLabel" id="label1">
  8271. <property name="visible">True</property>
  8272. <property name="ypad">5</property>
  8273. <property name="label" translatable="yes"> Spindle Up To Speed </property>
  8274. </object>
  8275. <packing>
  8276. <property name="expand">False</property>
  8277. <property name="fill">False</property>
  8278. <property name="position">0</property>
  8279. </packing>
  8280. </child>
  8281. <child>
  8282. <object class="HAL_LED" id="spindle-at-speed-led">
  8283. <property name="visible">True</property>
  8284. <property name="led_shape">2</property>
  8285. <property name="on_color">green</property>
  8286. <property name="led_size">5</property>
  8287. </object>
  8288. <packing>
  8289. <property name="expand">False</property>
  8290. <property name="fill">False</property>
  8291. <property name="padding">10</property>
  8292. <property name="position">1</property>
  8293. </packing>
  8294. </child>
  8295. </object>
  8296. <packing>
  8297. <property name="expand">False</property>
  8298. <property name="position">1</property>
  8299. </packing>
  8300. </child>""")
  8301. print >>file, ("""
  8302. <child>
  8303. <object class="HAL_Table" id="button-box-active">
  8304. <property name="visible">True</property>
  8305. <property name="n_rows">5</property>
  8306. <property name="homogeneous">False</property>""")
  8307. if self.widgets.autotouchz.get_active():
  8308. print >>file, ("""
  8309. <child>
  8310. <object class="HAL_HBox" id="auto-touch-z-active">
  8311. <property name="visible">True</property>
  8312. <child>
  8313. <object class="HAL_Button" id="auto-touch-z">
  8314. <property name="label" translatable="yes">Z Auto Touch Off</property>
  8315. <property name="visible">True</property>
  8316. <property name="can_focus">True</property>
  8317. <property name="receives_default">True</property>
  8318. <property name="yalign">0.56000000238418579</property>
  8319. </object>
  8320. <packing>
  8321. <property name="position">0</property>
  8322. </packing>
  8323. </child>
  8324. </object>
  8325. <packing>
  8326. <property name="top_attach">4</property>
  8327. <property name="bottom_attach">5</property>
  8328. </packing>
  8329. </child>""")
  8330. if self.widgets.zeroa.get_active():
  8331. print >>file, ("""
  8332. <child>
  8333. <object class="HAL_HBox" id="zero-a-active">
  8334. <property name="visible">True</property>
  8335. <child>
  8336. <object class="HAL_Button" id="zero-a">
  8337. <property name="label" translatable="yes">Zero A</property>
  8338. <property name="visible">True</property>
  8339. <property name="can_focus">True</property>
  8340. <property name="receives_default">True</property>
  8341. </object>
  8342. <packing>
  8343. <property name="position">0</property>
  8344. </packing>
  8345. </child>
  8346. </object>
  8347. <packing>
  8348. <property name="top_attach">3</property>
  8349. <property name="bottom_attach">4</property>
  8350. </packing>
  8351. </child>""")
  8352. if self.widgets.zeroz.get_active():
  8353. print >>file, ("""
  8354. <child>
  8355. <object class="HAL_HBox" id="zero-z-active">
  8356. <property name="visible">True</property>
  8357. <child>
  8358. <object class="HAL_Button" id="zero-z">
  8359. <property name="label" translatable="yes">Zero Z</property>
  8360. <property name="visible">True</property>
  8361. <property name="can_focus">True</property>
  8362. <property name="receives_default">True</property>
  8363. </object>
  8364. <packing>
  8365. <property name="position">0</property>
  8366. </packing>
  8367. </child>
  8368. </object>
  8369. <packing>
  8370. <property name="top_attach">2</property>
  8371. <property name="bottom_attach">3</property>
  8372. </packing>
  8373. </child>""")
  8374. if self.widgets.zeroy.get_active():
  8375. print >>file, ("""
  8376. <child>
  8377. <object class="HAL_HBox" id="zero-y-active">
  8378. <property name="visible">True</property>
  8379. <child>
  8380. <object class="HAL_Button" id="zero-y">
  8381. <property name="label" translatable="yes">Zero Y</property>
  8382. <property name="visible">True</property>
  8383. <property name="can_focus">True</property>
  8384. <property name="receives_default">True</property>
  8385. </object>
  8386. <packing>
  8387. <property name="position">0</property>
  8388. </packing>
  8389. </child>
  8390. </object>
  8391. <packing>
  8392. <property name="top_attach">1</property>
  8393. <property name="bottom_attach">2</property>
  8394. </packing>
  8395. </child>""")
  8396. if self.widgets.zerox.get_active():
  8397. print >>file, ("""
  8398. <child>
  8399. <object class="HAL_HBox" id="zero-x-active">
  8400. <property name="visible">True</property>
  8401. <child>
  8402. <object class="HAL_Button" id="zero-x">
  8403. <property name="label" translatable="yes">Zero X</property>
  8404. <property name="visible">True</property>
  8405. <property name="can_focus">True</property>
  8406. <property name="receives_default">True</property>
  8407. </object>
  8408. <packing>
  8409. <property name="position">0</property>
  8410. </packing>
  8411. </child>
  8412. </object>
  8413. </child>""")
  8414. print >>file, ("""
  8415. </object>
  8416. <packing>
  8417. <property name="expand">False</property>
  8418. <property name="fill">False</property>
  8419. <property name="position">2</property>
  8420. </packing>
  8421. </child>
  8422. </object>
  8423. </child>
  8424. </object>
  8425. </interface>""")
  8426. file.close()
  8427. # for classicladder test
  8428. def load_ladder(self,w):
  8429. newfilename = os.path.join(distdir, "configurable_options/ladder/TEMP.clp")
  8430. self.data.modbus = self.widgets.modbus.get_active()
  8431. self.halrun = halrun = os.popen("halrun -I > /dev/null", "w")
  8432. halrun.write("""
  8433. loadrt threads period1=%(period)d name1=fast fp1=0 period2=%(period2)d name2=slow
  8434. loadrt classicladder_rt numPhysInputs=%(din)d numPhysOutputs=%(dout)d numS32in=%(sin)d\
  8435. numS32out=%(sout)d numFloatIn=%(fin)d numFloatOut=%(fout)d
  8436. addf classicladder.0.refresh slow
  8437. start\n""" % {
  8438. 'din': self.widgets.digitsin.get_value(),
  8439. 'dout': self.widgets.digitsout.get_value(),
  8440. 'sin': self.widgets.s32in.get_value(),
  8441. 'sout': self.widgets.s32out.get_value(),
  8442. 'fin':self.widgets.floatsin.get_value(),
  8443. 'fout':self.widgets.floatsout.get_value(),
  8444. 'period':100000,
  8445. 'period2':self.data.servoperiod
  8446. })
  8447. if self.widgets.ladderexist.get_active() == True:
  8448. if self.data.tempexists:
  8449. self.data.laddername='TEMP.clp'
  8450. else:
  8451. self.data.laddername= 'blank.clp'
  8452. if self.widgets.ladder1.get_active() == True:
  8453. self.data.laddername= 'estop.clp'
  8454. if self.widgets.ladder2.get_active() == True:
  8455. self.data.laddername = 'serialmodbus.clp'
  8456. self.data.modbus = True
  8457. self.widgets.modbus.set_active(True)
  8458. if self.widgets.laddertouchz.get_active() == True:
  8459. self.data.laddertouchz = True
  8460. self.data.laddername = 'touchoff_z.clp'
  8461. self.data.halui = True
  8462. self.widgets.halui.set_active(True)
  8463. if self.widgets.ladderexist.get_active() == True:
  8464. self.data.laddername='custom.clp'
  8465. originalfile = filename = os.path.expanduser("~/linuxcnc/configs/%s/custom.clp" % self.data.machinename)
  8466. else:
  8467. filename = os.path.join(distdir, "configurable_options/ladder/"+ self.data.laddername)
  8468. if self.data.modbus == True:
  8469. halrun.write("loadusr -w classicladder --modmaster --newpath=%(newname)s %(filename)s\n" % {'newname':newfilename,'filename':filename})
  8470. else:
  8471. halrun.write("loadusr -w classicladder --newpath=%(newname)s %(filename)s\n" % { 'newname':newfilename ,'filename':filename })
  8472. halrun.write("start\n"); halrun.flush()
  8473. halrun.close()
  8474. if os.path.exists(newfilename):
  8475. self.data.tempexists = True
  8476. self.widgets.newladder.set_text('Edited ladder program')
  8477. self.widgets.ladderexist.set_active(True)
  8478. else:
  8479. self.data.tempexists = 0
  8480. # servo and stepper test
  8481. def tune_axis(self, axis):
  8482. if not self.check_for_rt(self):
  8483. return
  8484. d = self.data
  8485. w = self.widgets
  8486. self.updaterunning = False
  8487. axnum = "xyzas".index(axis)
  8488. self.axis_under_tune = axis
  8489. step_sig = self.data.stepgen_sig(axis)
  8490. self.stepgen = self.data.stepgen_sig(axis)
  8491. #print axis," stepgen--",self.stepgen
  8492. self.encoder = self.data.encoder_sig(axis)
  8493. #print axis," encoder--",self.encoder
  8494. pwm_sig = self.data.pwmgen_sig(axis)
  8495. self.pwm = self.data.make_pinname(pwm_sig)
  8496. #print axis," pwgen--",self.pwmgen
  8497. pump = self.data.findsignal("charge-pump")
  8498. w.tuneaxispage.set_current_page(axnum)
  8499. w[axis+"tunepage"].set_sensitive(1)
  8500. if self.stepgen:
  8501. w[axis+"tuningnotebook"].set_current_page(1)
  8502. w[axis+"pid"].set_sensitive(0)
  8503. w[axis+"tuneinvertencoder"].set_sensitive(0)
  8504. w[axis+"pidtable"].set_sensitive(0)
  8505. else:
  8506. w[axis+"tuningnotebook"].set_current_page(0)
  8507. w[axis+"step"].set_sensitive(0)
  8508. w[axis+"steptable"].set_sensitive(0)
  8509. text = _("Servo tuning is not avaiable in PNCconf yet\n")
  8510. self.warning_dialog(t