예제 #1
0
파일: tow.py 프로젝트: petebachant/Tow
 def closeEvent(self, event):
     acsc.stopBuffer(self.hcomm, 5)
     acsc.closeComm(self.hcomm)
     acsc.unregisterEmergencyStop()
     self.settings["Last window location"] = [self.pos().x(),
                                              self.pos().y()]
     self.settings["Mode index"] = self.ui.tabWidgetMode.currentIndex()
     for key, val in self.traverse_offset_actions.items():
         if val.isChecked():
             offset = key
     self.settings["Traverse offset"] = offset
     self.settings["Point-to-point"] = {
         "absolute": self.ui.rbAbsolute.isChecked(),
         "pos": self.ui.posSpinBox.value(),
         "vel": self.ui.velSpinBox.value(),
         "acc": self.ui.accSpinBox.value()}
     self.settings["Back-and-forth"] = {
         "absolute": self.ui.rbAbsolute_baf.isChecked(),
         "p1": self.ui.posSpinBox_baf1.value(),
         "p2": self.ui.posSpinBox_baf2.value(),
         "v1": self.ui.velSpinBox_baf1.value(),
         "v2": self.ui.velSpinBox_baf2.value(),
         "a1": self.ui.accSpinBox_baf1.value(),
         "a2": self.ui.accSpinBox_baf2.value(),
         "loop": self.ui.checkBox_loop.isChecked()}
     with open(self.settings_fpath, "w") as f:
         json.dump(self.settings, f, indent=4)
예제 #2
0
파일: tests.py 프로젝트: theja2289/ACSpy
def test_write_real():
    print("Testing acsc.writeReal")
    hc = acsc.openCommDirect()
    varname = "SLLIMIT1"
    val = 3.14
    acsc.writeReal(hc, varname, val)
    valread = acsc.readReal(hc, None, varname)
    acsc.closeComm(hc)
    print("Input value:", val)
    print("Value read:", valread)
    assert valread == val
    print("PASS")
예제 #3
0
파일: tests.py 프로젝트: theja2289/ACSpy
def test_upload_prg():
    """Test that a program can be uploaded and run in the simulator."""
    hc = acsc.openCommDirect()
    txt = "enable 0\nVEL(0) = 1333\nptp 0, 1.33\nSTOP"
    acsc.loadBuffer(hc, 19, txt, 64)
    acsc.runBuffer(hc, 19)
    time.sleep(0.2)
    vel = acsc.getVelocity(hc, 0)
    pos = acsc.getRPosition(hc, 0)
    print("Position:", pos)
    print("Velocity:", vel)
    assert vel == 1333.0
    assert pos == 1.33
    acsc.closeComm(hc)
예제 #4
0
for n in xrange(3):
    prg.addptp(0, 10000, "/e")
    prg.addptp(0, 0, "/e")
prg.addline("WAIT 10000")
prg.addline("STOPDC")
prg.addstopline()

acsc.setAcceleration(hc, 0, 10000)
acsc.loadBuffer(hc, 0, prg, 1024)
acsc.runBuffer(hc, 0)

astate = acsc.getAxisState(hc, 0)
#print astate

for n in xrange(3):
    time.sleep(sleeptime)
    newdata = acsc.readReal(hc, acsc.NONE, "data", 0, 1, 0, dblen/2-1)
    print acsc.readInteger(hc, acsc.NONE, "S_DCN")
    t = np.append(t, newdata[0])
    data = np.append(data, newdata[1])
    time.sleep(sleeptime)
    newdata = acsc.readReal(hc, acsc.NONE, "data", 0, 1, dblen/2, dblen-1)
    t = np.append(t, newdata[0])
    data = np.append(data, newdata[1])

print acsc.readReal(hc, acsc.NONE, "foo")
acsc.printLastError()
acsc.closeComm(hc)

plt.plot(t, data)
plt.show()
예제 #5
0
 def disconnect(self):
     acsc.closeComm(self.hc)
예제 #6
0
파일: prg_test.py 프로젝트: theja2289/ACSpy
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)
예제 #7
0
        time.sleep(.1)

    if scan_gain:
        for focal_idx, focal_position in enumerate(focal_step_mtx):
            gain_fill[focal_idx] = gainscan(1, focal_position)
            print("projecting at " + str(focal_position))
    acsc.toPoint(hcomm, None, 0, where_i_was)
    while (not acsc.getMotorState(hcomm, 0)['in position']
           ):  #check for stop event using other API call?
        time.sleep(.1)

if load_stages:
    while (not acsc.getMotorState(hcomm, 1)['in position']
           ):  #check for stop event using other API call?
        time.sleep(.1)
    acsc.closeComm(hcomm)
print(datetime.now() - startTime)
idx = 1

for proj_idx, projection in enumerate(projection_fill):
    gain_corrected_image = np.divide(projection,
                                     gain_fill[proj_idx],
                                     dtype=np.float32)
    dx.write_tiff(gain_corrected_image,
                  output_dir + "\\GC_Image_Focus_" +
                  str(focal_step_mtx[proj_idx]) + "_f" + str(proj_idx) +
                  ".tiff",
                  dtype=np.float32)

#PA_Set moves to absolute position
result, errString = ESP301Device.PA_Set(stage_axis, initial_position,
예제 #8
0
 def disconnect(self):
     acsc.closeComm(self.hc)
예제 #9
0
 def close(self):
     acsc.closeComm(self.hc)