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")
def run(self): if self.makeprg: self.makedaqprg() acsc.loadBuffer(self.hc, 19, self.prg, 1024) acsc.runBuffer(self.hc, 19) collect = acsc.readInteger(self.hc, acsc.NONE, "collect_data") while collect == 0: time.sleep(0.01) collect = acsc.readInteger(self.hc, acsc.NONE, "collect_data") while self.collectdata: time.sleep(self.sleeptime) t0 = acsc.readReal(self.hc, acsc.NONE, "start_time") newdata = acsc.readReal(self.hc, acsc.NONE, "data", 0, 2, 0, self.dblen//2-1) t = (newdata[0] - t0)/1000.0 self.data["time"] = np.append(self.data["time"], t) self.data["carriage_vel"] = np.append(self.data["carriage_vel"], newdata[1]) self.data["turbine_rpm"] = np.append(self.data["turbine_rpm"], newdata[2]) time.sleep(self.sleeptime) newdata = acsc.readReal(self.hc, acsc.NONE, "data", 0, 2, self.dblen//2, self.dblen-1) t = (newdata[0] - t0)/1000.0 self.data["time"] = np.append(self.data["time"], t) self.data["time"] = self.data["time"] - self.data["time"][0] self.data["carriage_vel"] = np.append(self.data["carriage_vel"], newdata[1]) self.data["turbine_rpm"] = np.append(self.data["turbine_rpm"], newdata[2])
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()
# -*- coding: utf-8 -*- """ Created on Mon Aug 26 23:26:33 2013 @author: Pete """ from acspy import acsc hc = acsc.openCommDirect() print acsc.readReal(hc, acsc.NONE, "FPOS(0)") acsc.closeComm(hc)
# -*- coding: utf-8 -*- """ Created on Mon Aug 26 23:26:33 2013 @author: Pete """ from __future__ import division, print_function from acspy import acsc hc = acsc.openCommDirect() print(acsc.readReal(hc, acsc.NONE, "FPOS(0)")) acsc.closeComm(hc)
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 range(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()