Esempio n. 1
0
 def on_enableAxis_click(self):
     if not self.axis_enabled:
         self.axis_enabled = True
         acsc.enable(self.hcomm, self.axis, acsc.SYNCHRONOUS)
         self.ui.enableAxis.setText("Disable")
     else:
         self.axis_enabled = False
         acsc.disable(self.hcomm, self.axis, acsc.SYNCHRONOUS)
         self.ui.enableAxis.setText("Enable")
Esempio n. 2
0
 def run(self):
     """Start the run. Comms should be open already with the controller."""
     if acsc.getOutput(self.hc, 1, 16):
         acsc.setOutput(self.hc, 1, 16, 0)
     if self.vectrino:
         acsc.enable(self.hc, 0)
         acsc.enable(self.hc, 1)
         while not acsc.getMotorState(self.hc, 0)["enabled"] or not \
                 acsc.getMotorState(self.hc, 1)["enabled"]:
             self.msleep(100)
         acsc.toPoint(self.hc, None, 0, self.y_R * self.R)
         acsc.toPoint(self.hc, None, 1, self.z_H * self.H)
         while not acsc.getMotorState(self.hc, 0)["in position"] or not \
                 acsc.getMotorState(self.hc, 1)["in position"]:
             self.msleep(300)
         print("y- and z-axes in position")
         acsc.disable(self.hc, 0)
         acsc.disable(self.hc, 1)
         self.vec.serial_port = "COM2"
         self.vec.connect()
         tstart = time.time()
         self.timeout = False
         self.vecstatus = "Connecting to Vectrino..."
         while not self.vec.connected:
             self.msleep(300)
             if time.time() - tstart > 10:
                 print("Vectrino timed out")
                 self.timeout = True
                 break
         if not self.timeout:
             self.vec.stop()
             self.setvecconfig()
             if self.recordvno:
                 self.vec.start_disk_recording(self.vecsavepath)
             self.vec.start()
             self.vecstatus = "Vectrino connected "
             while self.vec.state != "Confirmation mode":
                 self.msleep(100)
             print("Vectrino in data collection mode")
             print("Waiting 6 seconds")
             self.sleep(6)
             self.daqthread.start()
             if self.fbg:
                 self.fbgthread.start()
             self.start_motion()
     elif self.nidaq:
         self.daqthread.start()
         if self.fbg:
             self.fbgthread.start()
         self.start_motion()
     else:
         # Start motion
         self.start_motion()
Esempio n. 3
0
 def run(self):
     """Start the run. Comms should be open already with the controller."""
     if acsc.getOutput(self.hc, 1, 16):
         acsc.setOutput(self.hc, 1, 16, 0)
     if self.vectrino:
         acsc.enable(self.hc, 0)
         acsc.enable(self.hc, 1)
         while not acsc.getMotorState(self.hc, 0)["enabled"] or not \
                 acsc.getMotorState(self.hc, 1)["enabled"]:
             self.msleep(100)
         acsc.toPoint(self.hc, None, 0, self.y_R*self.R)
         acsc.toPoint(self.hc, None, 1, self.z_H*self.H)
         while not acsc.getMotorState(self.hc, 0)["in position"] or not \
                 acsc.getMotorState(self.hc, 1)["in position"]:
             self.msleep(300)
         print("y- and z-axes in position")
         acsc.disable(self.hc, 0)
         acsc.disable(self.hc, 1)
         self.vec.serial_port = "COM2"
         self.vec.connect()
         tstart = time.time()
         self.timeout = False
         self.vecstatus = "Connecting to Vectrino..."
         while not self.vec.connected:
             self.msleep(300)
             if time.time() - tstart > 10:
                 print("Vectrino timed out")
                 self.timeout = True
                 break
         if not self.timeout:
             self.vec.stop()
             self.setvecconfig()
             if self.recordvno:
                 self.vec.start_disk_recording(self.vecsavepath)
             self.vec.start()
             self.vecstatus = "Vectrino connected "
             while self.vec.state != "Confirmation mode":
                 self.msleep(100)
             print("Vectrino in data collection mode")
             print("Waiting 6 seconds")
             self.sleep(6)
             self.daqthread.start()
             if self.fbg:
                 self.fbgthread.start()
             self.start_motion()
     elif self.nidaq:
         self.daqthread.start()
         if self.fbg:
             self.fbgthread.start()
         self.start_motion()
     else:
         # Start motion
         self.start_motion()
Esempio n. 4
0
 def start_motion(self):
     self.acsdaqthread.start()
     nbuf = 19
     acsc.loadBuffer(self.hc, nbuf, self.acs_prg, 2048)
     acsc.enable(self.hc, 4)
     acsc.runBuffer(self.hc, nbuf)
     prgstate = acsc.getProgramState(self.hc, nbuf)
     while prgstate == 3:
         time.sleep(0.3)
         prgstate = acsc.getProgramState(self.hc, nbuf)
     self.acsdaqthread.stop()
     self.daqthread.clear()
     self.runfinished.emit()
Esempio n. 5
0
 def start_motion(self):
     self.acsdaqthread.start()
     nbuf = 19
     acsc.loadBuffer(self.hc, nbuf, self.acs_prg, 2048)
     acsc.enable(self.hc, 4)
     acsc.runBuffer(self.hc, nbuf)
     prgstate = acsc.getProgramState(self.hc, nbuf)
     while prgstate == 3:
         time.sleep(0.3)
         prgstate = acsc.getProgramState(self.hc, nbuf)
     self.acsdaqthread.stop()
     self.daqthread.clear()
     self.runfinished.emit()
Esempio n. 6
0
 def start_motion(self):
     self.acsdaqthread.start()
     nbuf = 19
     acsc.loadBuffer(self.hc, nbuf, self.acs_prg, 2048)
     acsc.enable(self.hc, 4)
     acsc.enable(self.hc, 5)
     acsc.runBuffer(self.hc, nbuf)
     prgstate = acsc.getProgramState(self.hc, nbuf)
     while prgstate == 3:
         time.sleep(0.3)
         prgstate = acsc.getProgramState(self.hc, nbuf)
     self.acsdaqthread.stop()
     if self.nidaq:
         self.daqthread.clear()
         print("NI tasks cleared")
     if self.fbg:
         self.fbgthread.stop()
     if self.vectrino:
         if self.settling:
             # Wait 10 minutes to measure tank settling time
             print("Waiting 10 minutes")
             t0 = time.time()
             dt = 0.0
             while not self.aborted and dt < 600:
                 time.sleep(0.5)
                 dt = time.time() - t0
         if self.recordvno:
             self.vec.stop_disk_recording()
         self.vec.stop()
         self.vec.disconnect()
     print("Tow finished")
     if self.vectrino:
         if self.vec.state == "Not connected":
             self.vecstatus = "Vectrino disconnected "
         print("Resetting Vectrino")
         self.reset_vec()
     self.towfinished.emit()
Esempio n. 7
0
 def start_motion(self):
     self.acsdaqthread.start()
     nbuf = 19
     acsc.loadBuffer(self.hc, nbuf, self.acs_prg, 2048)
     acsc.enable(self.hc, 4)
     acsc.enable(self.hc, 5)
     acsc.runBuffer(self.hc, nbuf)
     prgstate = acsc.getProgramState(self.hc, nbuf)
     while prgstate == 3:
         time.sleep(0.3)
         prgstate = acsc.getProgramState(self.hc, nbuf)
     self.acsdaqthread.stop()
     if self.nidaq:
         self.daqthread.clear()
         print("NI tasks cleared")
     if self.fbg:
         self.fbgthread.stop()
     if self.vectrino:
         if self.settling:
             # Wait 10 minutes to measure tank settling time
             print("Waiting 10 minutes")
             t0 = time.time()
             dt = 0.0
             while not self.aborted and dt < 600:
                 time.sleep(0.5)
                 dt = time.time() - t0
         if self.recordvno:
             self.vec.stop_disk_recording()
         self.vec.stop()
         self.vec.disconnect()
     print("Tow finished")
     if self.vectrino:
         if self.vec.state == "Not connected":
             self.vecstatus = "Vectrino disconnected "
         print("Resetting Vectrino")
         self.reset_vec()
     self.towfinished.emit()
Esempio n. 8
0
 def enable_axis(self, axis, wait=acsc.SYNCHRONOUS):
     if axis in self.axisdefs:
         axis = self.axisdefs[axis]
     acsc.enable(self.hc, axis, wait)
Esempio n. 9
0
then uploading it to the controller and running it.
"""

from __future__ import division, print_function
from acspy import acsc
import time

#file = open("test/test.prg", "w+")

acs_prg = """
ENABLE 1""" + \
"""
VEL(1) = 1000
PTP/r 1, -900
STOP
"""

#file.write(acs_prg)
#file.close()

print(acs_prg)
hc = acsc.openCommDirect()
acsc.loadBuffer(hc, 0, acs_prg, 512)
acsc.enable(hc, 0)
#acsc.LoadBuffersFromFile(hc, "test/test.prg")
acsc.runBuffer(hc, 0)
time.sleep(1)
print(acsc.getRPosition(hc, 1))
print(acsc.getMotorState(hc, 1))
acsc.closeComm(hc)
Esempio n. 10
0
            image_npy = np.reshape(data, (height, width))
        else:
            mmc.snapImage()
            image_npy = mmc.getImage()
        proj_32bit_filler = proj_32bit_filler + image_npy
    return proj_32bit_filler


##################
####stage calls###
##################
if load_stages:
    #initiate connection
    hcomm = acsc.openCommEthernetTCP(address="10.0.0.100", port=701)
    if scan_gain:
        acsc.enable(hcomm, 0)  #z
        # acsc.toPoint(hcomm, None,0,110) #YIFU CHECK THIS
        acsc.setVelocity(hcomm, 0, 5)  #velocity in mm/sec
        r_pos_0 = acsc.getRPosition(hcomm, 0)
        f_pos_0 = acsc.getFPosition(hcomm, 0)

    acsc.enable(hcomm, 1)  #theta
    acsc.setVelocity(hcomm, 1, 5)  #velocity in degrees/sec
    r_pos_1 = acsc.getRPosition(hcomm, 1)
    f_pos_1 = acsc.getFPosition(hcomm, 1)
    # acsc.toPoint(hcomm, None,1,0)
    print("z-stage F pos: %f \n z-stage R pos: %f" % (f_pos_0, r_pos_0))
    print("theta-stage F pos: %f \n theta-stage R pos: %f" %
          (f_pos_1, r_pos_1))
    where_i_was = r_pos_0
Esempio n. 11
0
 def enable(self, wait=acsc.SYNCHRONOUS):
     acsc.enable(self.controller.hc, self.axisno, wait)
Esempio n. 12
0
 def enable(self, wait=acsc.SYNCHRONOUS):
     acsc.enable(self.controller.hc, self.axisno, wait)
    #exposure=60
    print(device_id)
    mmc.setExposure(exposure_inpt)
    mmc.setProperty(device_id, "Binning", binning_value)
    print(mmc.getProperty(device_id, "Binning"))
    os.chdir(prev_dir)

##################
####stage calls###
##################
if load_stages:
    #initiate connection
    hcomm = acsc.openCommEthernetTCP(address="10.0.0.100", port=701)
    #z
    if scan_gain:
        acsc.enable(hcomm, 0)
        acsc.toPoint(hcomm, None, 0, 110)  #YIFU CHECK THIS
        acsc.setVelocity(hcomm, 0, 5)  #velocity in mm/sec
    #theta
    acsc.enable(hcomm, 1)
    acsc.setVelocity(hcomm, 1, 10)  #velocity in degrees/sec
    acsc.setJerk(hcomm, 1, 500)  #jerk, normal is 9000
    acsc.setDeceleration(hcomm, 1, 450)  #jerk, normal is 9000
    acsc.setAcceleration(hcomm, 1, 450)  #Acceleration, normal is 9000
    acsc.toPoint(hcomm, None, 1, 0)

#Actually do the imaging
if do_scan:
    for idx in range(degrees_array.shape[0]):
        q = time.time()
        set_degree = degrees_array[idx]
Esempio n. 14
0
"""
This is a test for generating an ACSPL+ program
then uploading it to the controller and running it.
"""
from acspy import acsc
import time

#file = open("test/test.prg", "w+")

acs_prg = """
ENABLE 1""" + \
"""
VEL(1) = 1000
PTP/r 1, -900
STOP
"""

#file.write(acs_prg)
#file.close()

print acs_prg
hc = acsc.openCommDirect()
acsc.loadBuffer(hc, 0, acs_prg, 512)
acsc.enable(hc, 0)
#acsc.LoadBuffersFromFile(hc, "test/test.prg")
acsc.runBuffer(hc, 0)
time.sleep(1)
print acsc.getRPosition(hc, 1)
print acsc.getMotorState(hc, 1)
acsc.closeComm(hc)