Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3 #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions sardana_pandabox/ctrl/PandaboxCoTiCtrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from pandaboxlib import PandA
import time
import socket
from sockio.py2 import TCP
from StringIO import StringIO
from sockio.sio import TCP
from io import StringIO
import numpy as np

from sardana import State, DataAccess
Expand Down Expand Up @@ -72,7 +72,7 @@ def __init__(self, inst, props, *args, **kwargs):
ack = self.data_socket.write_readline('\n')
if "OK" not in ack:
raise Exception('Acknowledge to data stream failed!')
print "PandaboxCoTiCtrl: data stream listener starts...", ack
print("PandaboxCoTiCtrl: data stream listener starts...", ack)
self.data_buffer = ""
self.header_okay_flag = False
self.data_end_flag = False
Expand Down Expand Up @@ -201,7 +201,7 @@ def StartAllCT(self):
# self._log.debug("StartAllCT(): Entering...")
ret = self.pandabox.query('*PCAP.ARM=')
if "OK" not in ret:
print "Pandabox arm PCAP failed. Disarm and arm again..."
print("Pandabox arm PCAP failed. Disarm and arm again...")
ret = self.pandabox.query('*PCAP.DISARM=')
ret = self.pandabox.query('*PCAP.ARM=')

Expand Down Expand Up @@ -237,23 +237,23 @@ def ReadAll(self):
#self.index = 0

if self.data_ready == 0:
print "Pandabox: No data available yet."
print("Pandabox: No data available yet.")
self._ParseHeader()
return
elif self.data_ready <= self._repetitions:
if self.data_ready == self._repetitions:
print "Pandabox data acquisition has finished, disabling PCAP..."
print("Pandabox data acquisition has finished, disabling PCAP...")
self.pandabox.query('PCAP.ENABLE=ZERO') # it disarms PCAP too
try:
if not self.data_end_flag:
data = self.data_socket.readline()
if 'END' not in data:
self.data_buffer += data
else:
print "Pandabox data acquisition ENDs okay!"
print("Pandabox data acquisition ENDs okay!")
self.data_end_flag = True
except socket.error, e:
print "Pandabox: data socket error: ", e
except socket.error as e:
print("Pandabox: data socket error: ", e)
self.data_socket.close()

data_only = np.genfromtxt(StringIO(self.data_buffer), dtype='float64')
Expand Down Expand Up @@ -327,10 +327,10 @@ def _ParseHeader(self):
try:
data_header = self.data_socket.readlines(num_lines+1) #+1 blank line
if "fields" in data_header[3]:
print "Pandabox data header parsing okay!"
print("Pandabox data header parsing okay!")
self.header_okay_flag = True
except socket.error, e:
print "Pandabox: socket error header!!!! = ", e
except socket.error as e:
print("Pandabox: socket error header!!!! = ", e)
self.header_okay_flag = False
pass

Expand Down Expand Up @@ -419,8 +419,8 @@ def GetCtrlPar(self, parameter):
ctrl.StateAll()
ctrl.ReadAll()
time.sleep(0.25)
print "Time: ", time.time() - t0 - acqtime
print "COUNTER1.OUT = ", ctrl.ReadOne(2)
print "INENC1.VAL = ", ctrl.ReadOne(3)
print("Time: ", time.time() - t0 - acqtime)
print("COUNTER1.OUT = ", ctrl.ReadOne(2))
print("INENC1.VAL = ", ctrl.ReadOne(3))