# This code is part of the x1Mill_handler.py for the associated x1Mill.ui # Copyright (c) 2018 Johannes P Fassotte # This gui is for use with linuxcnc QTVcp by Chris Morley # # This code is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # This code raeds the .int file and gerates three lists that can # have up 20 values each for use with the jogging functions in the # x1mill gui. # # These values are used by other code to name the buttons, and also # set the true state value for the buttons. Ether the button name or # true state value can be routed with additional available code within # the gui to jog the specicic increment. # # If not all 20 values for each list are used they will have a value # of -1 which can be used to hide any buttons not being used. # # When switching from inch to mm in the x1mill gui it may be desireable # to have a meteric jog increment vaule that is acatually in mm instead # of convering a inch value to metric and have it display is a value # that has more meaning. For example a button that has a marked value # in inches of 0.7500 would be 19.050 which to me is confusing. It is # therefore deirable to always have a inch and a mm list so both lists # can be optimized for thier specific use and display thier values with # no confusuion. # # # This is a sample of float data produced for the increment files. # # inch_incr_list [1.0, 0.75, 0.5, 0.25, 0.1, 0.075, 0.05, 0.025, 0.01, # 0.0075, 0.005, 0.0025, 0.001, 0.00075, 0.0005, 0.00025, # -1, -1, -1, -1, 0.25, 0, 1] # # mm_incr_list [25.4, 10.0, 7.5, 5.0, 2.5, 1.0, 0.75, 0.5, 0.25, 0.1, # 0.075, 0.05, 0.025, 0.01, 0.0075, 0.005, -1, -1, -1, -1, # 10.0, 1, -1] # # ang_incr_list [0.1, 1.0, 5.0, 10.0, 15.0, 30.0, 45.0, 60.0, 75.0, 90.0, # 105.0, 120.0, 135.0, 150.0, 165.0, 180.0, -1, -1, -1, -1, # 45.0, 1, -1] # [0] to [19] increment data # [20] = the defaut jog step from ini file # [21] = values label is always 0 for inch and 1 for mm. # [22] = used to mark table as being the active one for switching purposes # # If a default jog step matches the value of a button in that particular # list that button is set to true by other code. The default value if # there is no match is discarded after a button is pushed by present code. # It is assumed that the default value will always be one of the values # in the list of values. # # Some of the pictures I have posted show the labing of the buttons but do not # show the updated gui that has 20 buttons for each of the three panels instead # of the 16. # # ini file items # # [TRAJ] # LINEAR_UNITS = inch # ANGULAR_UNITS = degree # # [X1GUI] # LINEAR_INCR_INCH = 1.0000,0.7500,0.5000,0.2500,0.1000,0.0750,0.0500, # 0.0250,0.0100,0.0075,0.0050,0.0025,0.0010,0.00075, # 0.0005,0.00025 # # LINEAR_INCR_MM = 25.400,10.000,7.500,5.000,2.500,1.000,0.750,0.500, # 0.250,0.100,0.075,0.050,0.025,0.010,0.0075,0.005 # # ANGULAR_INCR = 0.1,1,5,10,15,30,45,60,75,90,105,120,135,150,165,180 # # LINEAR_INCR_DEFAULT = 0.2500 # LINEAR_INCR_MM_DEFAULT = 10.000 # ANGULAR_INCR_DEFAULT = 45 # # # get machine configuration information to share between functions # ============================================================================================== def get_general_info(self): self.machine_control = range(3) self.machine_control[0:] = [-1] * 3 # Linear units: in,inch,imperial=0 mm,metric=1 unitsl = self.inifile.find("TRAJ", "LINEAR_UNITS") if unitsl in ['in', 'inch', 'imperial']: self.machine_control[0] = 0 # machine unis are in inches if unitsl in ['mm', 'metric']: self.machine_control[0] = 1 # machine unis are in mm # angular units: deg=0, degree=1, rad=2, radian=3, grad=4, gon=5 unitsa = self.inifile.find("TRAJ", "ANGULAR_UNITS") self.machine_control[1]=['deg','degree','rad','radian','grad','gon'].index(unitsa) # More items will be added as needed # make increment lists for jogging # ============================================================================================== def gen_jogging_increment_lists(self): print "getting all jogging increments" # increment list processing for 'inch' table # up to 20 values for the 20 jogging buttons - not used will have [-1] (hide button) # last three items are: [20]=default increment,[21]=data type,[22]=table active or not inch_incrs = range(23) inch_incrs[0:] = [-1] * 23 inch_incr = self.inifile.find("X1GUI", "LINEAR_INCR_INCH") inch_default_incr = self.inifile.find("X1GUI", "LINEAR_INCR_INCH_DEFAULT") inch_incrs[20] = float(inch_default_incr) # the defaut jog step from ini file inch_incrs[21] = 0 # table values are in inches if self.machine_control[0] == 0: # machine units are in inch inch_incrs[22] = 1 # used to mark table as being the active one inch_incr = list(inch_incr.split(',')) if inch_default_incr == None: inch_incr.insert(len(inch_incr),('0')) else: inch_list = [float(i) for i in inch_incr ] a=0 for i in inch_incr: inch_incrs[a]=inch_list[a] a=a+1 self.inch_incr_list = inch_incrs # mm increment list processing mm_incrs = range(23) mm_incrs[0:] = [-1] * 23 mm_incr = self.inifile.find("X1GUI", "LINEAR_INCR_MM") mm_default_incr = self.inifile.find("X1GUI", "LINEAR_INCR_MM_DEFAULT") mm_incrs[20] = float(mm_default_incr) # the defaut jog step from ini file mm_incrs[21] = 1 # table values are in mm if self.machine_control[0] == 1: # machine units are in mm mm_incrs[22] = 1 # used to mark table as being the active one mm_incr = list(mm_incr.split(',')) if mm_default_incr == None: mm_incr.insert(len(mm_incr),('0')) else: mm_list = [float(i) for i in mm_incr ] a=0 for i in mm_incr: mm_incrs[a]=mm_list[a] a=a+1 self.mm_incr_list = mm_incrs # ang increment list processing ang_incrs = range(23) ang_incrs[0:] = [-1] * 23 ang_units = self.inifile.find("TRAJ", "ANGULAR_UNITS") ang_incr = self.inifile.find("X1GUI", "ANGULAR_INCR") ang_default_incr = self.inifile.find("X1GUI", "ANGULAR_INCR_DEFAULT") ang_incrs[20] = float(ang_default_incr) # the defaut jog step from ini file ang_incrs[21] = self.machine_control[1] # angular units type 0,1,2,3,4,5 ang_incrs[22] = -1 # used to mark table as being active later ang_incr = list(ang_incr.split(',')) if ang_default_incr == None: ang_incr.insert(len(ang_incr),('0')) else: ang_list = [float(i) for i in ang_incr ] a=0 for i in ang_incr: ang_incrs[a]=ang_list[a] a=a+1 self.ang_incr_list = ang_incrs # print "inch_incr_list", self.inch_incr_list # print "mm_incr_list", self.mm_incr_list # print "ang_incr_list", self.ang_incr_list