
# this is just an example of how to acquire Maxipix image and to display
# using Qub. 
# First start ipython with the following command and then execute the code
# step by step:
#   QUB_SUBPATH=qt4 ipython -q4thread 


from Qub.Widget.DataDisplay.QubDataImageDisplay import QubDataImageDisplay
import time
from Lima.Maxipix.MpxAcq import MpxAcq
from Lima import Core
from Lima.Core import DebParams

DebParams.setTypeFlags(DebParams.AllFlags)
DebParams.setModuleFlags(DebParams.AllFlags)
DebParams.setFormatFlags(DebParams.AllFlags)

DebParams.setModuleFlags(0xffffb7)

class MyCbk(Core.CtControl.ImageStatusCallback) :
	def imageStatusChanged(self,img_status) :
	    im = c.ReadImage()
	    if im:
		w.setData(im.buffer)
            print img_status

w = QubDataImageDisplay()
w.show()

a = MpxAcq(0); p = a.getPriamAcq()
a.setPath('/users/blissadm/local/maxipix/')
a.loadConfig('mxratl3_2010-03-05')
c = a.getControl()
acq = c.acquisition()

Cbk = MyCbk()
c.registerImageStatusCallback(Cbk)

def acquisition(frames,exposure):
 acq.setAcqNbFrames(frames)
 acq.setAcqExpoTime(exposure)

 c.prepareAcq()
 c.startAcq()








