Example #1
0
    (at your option) any later version.

    AutoPatcher_IG 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.

    You should have received a copy of the GNU General Public License
    along with AutoPatcher_IG.  If not, see <http://www.gnu.org/licenses/>.

@Author: Brendan Callahan, Alexander A. Chubykin
"""

import MSSInterface
import time
MSSInterface = MSSInterface.MSSInterface()
time.sleep(5)
# while True:
# 	print "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",MSSInterface.getCoords(2,0)
# 	print "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",MSSInterface.getCoords(2,0)

# 	MSSInterface.moveToRel(2,0, 100, 100, 100)
# 	MSSInterface.waitForReady(2,0)
# 	MSSInterface.askCoords(2,0)
# 	print "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",MSSInterface.getCoords(2,0)
# 	print "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",MSSInterface.getCoords(2,0)

# 	print "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",MSSInterface.getCoords(2,0)
# 	print "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",MSSInterface.getCoords(2,0)

# 	MSSInterface.moveToRel(2,0, -100, -100, -100)
Example #2
0
 def get_motors_coord_um(self, manip=None): # returns the motor coordinates in um
     print "GETTING COORDS FOR UNIT ",self.unitID
     coord=[]        
     #no manipulator defined, all motors
     if manip == None:
         startmot = 1
         endmot = 7
     #first manipulator only
     if manip == 0:
         startmot = 1
         endmot = 4
     #second manipulator only
     if manip == 1:
         startmot = 4
         endmot = 7
     for i in range(startmot,endmot):
         a='#'+str(i)+'?Z' 
         
         b=self.talk(a)
         
         if i == 1:
             if "E+" in b:
                 #print "END POS UNIT:",self.unitID,"AXIS: X0+"
                 self.x0EndPosPlus = True
             else:
                 self.x0EndPosPlus = False
             if "E-" in b:
                 #print "END POS UNIT:",self.unitID,"AXIS: X0-"
                 self.x0EndPosMinus = True
             else:
                 self.x0EndPosMinus = False
         if i == 2:
             if "E+" in b:
                 #print "END POS UNIT:",self.unitID,"AXIS: Y0+"
                 self.y0EndPosPlus = True
             else:
                 self.y0EndPosPlus = False
             if "E-" in b:
                 #print "END POS UNIT:",self.unitID,"AXIS: Y0-"
                 self.y0EndPosMinus = True
             else:
                 self.y0EndPosMinus = False
         if i == 3:
             if "E+" in b:
                 #print "END POS UNIT:",self.unitID,"AXIS: Z0+"
                 self.z0EndPosPlus = True
             else:
                 self.z0EndPosPlus = False
             if "E-" in b:
                 #print "END POS UNIT:",self.unitID,"AXIS: Z0-"
                 self.z0EndPosMinus = True
             else:
                 self.z0EndPosMinus = False           
         if i == 4:
             if "E+" in b:
                 #print "END POS UNIT:",self.unitID,"AXIS: X1+"
                 self.x1EndPosPlus = True
             else:
                 self.x1EndPosPlus = False
             if "E-" in b:
                 #print "END POS UNIT:",self.unitID,"AXIS: X1-"
                 self.x1EndPosMinus = True
             else:
                 self.x1EndPosMinus = False
         if i == 5:
             if "E+" in b:
                 #print "END POS UNIT:",self.unitID,"AXIS: Y1+"
                 self.y1EndPosPlus = True
             else:
                 self.y1EndPosPlus = False
             if "E-" in b:
                 #print "END POS UNIT:",self.unitID,"AXIS: Y1-"
                 self.y1EndPosMinus = True
             else:
                 self.y1EndPosMinus = False
         if i == 6:
             if "E+" in b:
                 #print "END POS UNIT:",self.unitID,"AXIS: Z1+"
                 self.z1EndPosPlus = True
             else:
                 self.z1EndPosPlus = False
             if "E-" in b:
                 #print "END POS UNIT:",self.unitID,"AXIS: Z1-"
                 self.z1EndPosMinus = True
             else:
                 self.z1EndPosMinus = False            
         
         if self.unitID == 0:
             print b
         if b == None:
             self.parent.threadqueue[self.unitID].insert(0,mssi.askCoordsThread(self.parent,self.unitID))
             return
         if 'P' in b:
             #print "COORDS UNIT",self.unitID,"MANIP",i
             #print "B equals",b
             coordstring = b[b.index('P')+1:-4]
             #print "String equals",coordstring
             fullsteps = float(coordstring[:-2])
             microsteps = int(coordstring[-2:])
             #print "fullsteps",fullsteps
             #print "microsteps",microsteps
             sign = "+"                
             
             if fullsteps < 0:
                 fullsteps +=1
                 sign = "-"
             #print "fullsteps after increment",fullsteps
             
             actualcoords = fullsteps*self.full_step
             
             #print "actualcoords pre microsteps",actualcoords
             
             if sign == "+":
                 #print "MICROSTEP DISTANCE+:",((float(microsteps)*2.0)/100.0)*self.full_step
                 actualcoords += ((float(microsteps)*2.0)/100.0)*self.full_step
             else:
                 #print "MICROSTEP DISTANCE-:",(((50-float(microsteps))*2.0)/100.0)*self.full_step
                 actualcoords -= (((50-float(microsteps))*2.0)/100.0)*self.full_step
             #print "actualcoords post microsteps",actualcoords
             
             coord.append(round(float(actualcoords),5)) # recalculate in um, full_step is 1 step in mm
         else: # if didn't get through, repeat
             b=self.talk(a)
             coord.append(round(float(b[b.index('P')+1:-3])*self.full_step,4))
     if manip == None:
         self.parent.motorcoordinates[self.unitID][0]=copy.deepcopy(coord[:3])
         if self.parent.portdata[self.unitID][2] == 2:
             self.parent.motorcoordinates[self.unitID][1]=copy.deepcopy(coord[3:])
     if manip == 0:
         self.parent.motorcoordinates[self.unitID][0]=copy.deepcopy(coord[:3])
     if manip == 1:
         self.parent.motorcoordinates[self.unitID][1]=copy.deepcopy(coord[:3])
Example #3
0
    def get_motors_coord_um(self,
                            manip=None):  # returns the motor coordinates in um
        print "GETTING COORDS FOR UNIT ", self.unitID
        coord = []
        #no manipulator defined, all motors
        if manip == None:
            startmot = 1
            endmot = 7
        #first manipulator only
        if manip == 0:
            startmot = 1
            endmot = 4
        #second manipulator only
        if manip == 1:
            startmot = 4
            endmot = 7
        for i in range(startmot, endmot):
            a = '#' + str(i) + '?Z'

            b = self.talk(a)

            if i == 1:
                if "E+" in b:
                    #print "END POS UNIT:",self.unitID,"AXIS: X0+"
                    self.x0EndPosPlus = True
                else:
                    self.x0EndPosPlus = False
                if "E-" in b:
                    #print "END POS UNIT:",self.unitID,"AXIS: X0-"
                    self.x0EndPosMinus = True
                else:
                    self.x0EndPosMinus = False
            if i == 2:
                if "E+" in b:
                    #print "END POS UNIT:",self.unitID,"AXIS: Y0+"
                    self.y0EndPosPlus = True
                else:
                    self.y0EndPosPlus = False
                if "E-" in b:
                    #print "END POS UNIT:",self.unitID,"AXIS: Y0-"
                    self.y0EndPosMinus = True
                else:
                    self.y0EndPosMinus = False
            if i == 3:
                if "E+" in b:
                    #print "END POS UNIT:",self.unitID,"AXIS: Z0+"
                    self.z0EndPosPlus = True
                else:
                    self.z0EndPosPlus = False
                if "E-" in b:
                    #print "END POS UNIT:",self.unitID,"AXIS: Z0-"
                    self.z0EndPosMinus = True
                else:
                    self.z0EndPosMinus = False
            if i == 4:
                if "E+" in b:
                    #print "END POS UNIT:",self.unitID,"AXIS: X1+"
                    self.x1EndPosPlus = True
                else:
                    self.x1EndPosPlus = False
                if "E-" in b:
                    #print "END POS UNIT:",self.unitID,"AXIS: X1-"
                    self.x1EndPosMinus = True
                else:
                    self.x1EndPosMinus = False
            if i == 5:
                if "E+" in b:
                    #print "END POS UNIT:",self.unitID,"AXIS: Y1+"
                    self.y1EndPosPlus = True
                else:
                    self.y1EndPosPlus = False
                if "E-" in b:
                    #print "END POS UNIT:",self.unitID,"AXIS: Y1-"
                    self.y1EndPosMinus = True
                else:
                    self.y1EndPosMinus = False
            if i == 6:
                if "E+" in b:
                    #print "END POS UNIT:",self.unitID,"AXIS: Z1+"
                    self.z1EndPosPlus = True
                else:
                    self.z1EndPosPlus = False
                if "E-" in b:
                    #print "END POS UNIT:",self.unitID,"AXIS: Z1-"
                    self.z1EndPosMinus = True
                else:
                    self.z1EndPosMinus = False

            if self.unitID == 0:
                print b
            if b == None:
                self.parent.threadqueue[self.unitID].insert(
                    0, mssi.askCoordsThread(self.parent, self.unitID))
                return
            if 'P' in b:
                #print "COORDS UNIT",self.unitID,"MANIP",i
                #print "B equals",b
                coordstring = b[b.index('P') + 1:-4]
                #print "String equals",coordstring
                fullsteps = float(coordstring[:-2])
                microsteps = int(coordstring[-2:])
                #print "fullsteps",fullsteps
                #print "microsteps",microsteps
                sign = "+"

                if fullsteps < 0:
                    fullsteps += 1
                    sign = "-"
                #print "fullsteps after increment",fullsteps

                actualcoords = fullsteps * self.full_step

                #print "actualcoords pre microsteps",actualcoords

                if sign == "+":
                    #print "MICROSTEP DISTANCE+:",((float(microsteps)*2.0)/100.0)*self.full_step
                    actualcoords += (
                        (float(microsteps) * 2.0) / 100.0) * self.full_step
                else:
                    #print "MICROSTEP DISTANCE-:",(((50-float(microsteps))*2.0)/100.0)*self.full_step
                    actualcoords -= (((50 - float(microsteps)) * 2.0) /
                                     100.0) * self.full_step
                #print "actualcoords post microsteps",actualcoords

                coord.append(
                    round(float(actualcoords),
                          5))  # recalculate in um, full_step is 1 step in mm
            else:  # if didn't get through, repeat
                b = self.talk(a)
                coord.append(
                    round(float(b[b.index('P') + 1:-3]) * self.full_step, 4))
        if manip == None:
            self.parent.motorcoordinates[self.unitID][0] = copy.deepcopy(
                coord[:3])
            if self.parent.portdata[self.unitID][2] == 2:
                self.parent.motorcoordinates[self.unitID][1] = copy.deepcopy(
                    coord[3:])
        if manip == 0:
            self.parent.motorcoordinates[self.unitID][0] = copy.deepcopy(
                coord[:3])
        if manip == 1:
            self.parent.motorcoordinates[self.unitID][1] = copy.deepcopy(
                coord[:3])