Commit b18482a2 authored by Yuelong Yu's avatar Yuelong Yu
Browse files

working on pco4000

parent a4d8be7b
......@@ -55,7 +55,7 @@ namespace PcoNS
if(!(pco_loader.OpenLib(libpath)))
{
cerr << "Error opening :" << libpath
<< "det type : "<< det_type << endl;
<< " - det type : "<< det_type << endl;
return nullptr;
}
......
......@@ -27,6 +27,47 @@ namespace PcoNS
}
int Pco4000::SetCamera(shared_ptr<CPco_com>& sptrCamera,shared_ptr<CPco_grab_cl_me4>& sptrGrabber)
{
PcoProduct::SetCamera(sptrCamera,sptrGrabber);
if(m_camera_desc.wNumADCsDESC > 1)
if(SetADCOperation(2) != OK )
return SET_ERROR;
return OK;
}
int Pco4000::GetPixelRate(int& nPixelRate)
{
unsigned int unTmp;
if(m_sptrCamera->PCO_GetPixelRate(&unTmp) != OK)
return GET_ERROR;
if(unTmp == 32000000)
nPixelRate = 32;
else if(unTmp == 8000000)
nPixelRate = 8;
else
return GET_ERROR;
return OK;
}
int Pco4000::SetPixelRate(int nPixelRate)
{
if(nPixelRate == 8)
nPixelRate = 8000000;
else if(nPixelRate == 32)
nPixelRate = 32000000;
else
return SET_ERROR;
if(m_sptrCamera->PCO_SetPixelRate((unsigned int)nPixelRate) != OK)
return SET_ERROR;
return ArmCamera();
}
int Pco4000::GetCoolingSetpointTemperature(short& shTemperature)
{
if(m_sptrCamera->PCO_GetCoolingSetpointTemperature(&shTemperature) != OK)
......@@ -91,49 +132,85 @@ namespace PcoNS
int Pco4000::PreAcq()
{
if(SetRecordingState(0) != OK )
return SET_ERROR;
if(m_sptrCamera->PCO_ResetSettingsToDefault() != OK)
return SET_ERROR;
short shX,shY;
int nRet;
stTransferParams stData;
if((nRet = GetSizes(shX,shY)) != OK )
return nRet;
//check current frame grabber settings
unsigned int unCurrentX,unCurrentY,unCurrentDepth;
m_sptrGrabber->Get_actual_size(&unCurrentX,&unCurrentY,&unCurrentDepth);
if((nRet = GetTransferParameter(stData)) != OK )
return nRet;
if(m_sptrCamera->PCO_SetBitAlignment(BIT_ALIGNMENT_LSB) != OK)
return SET_ERROR;
if(stData.Transmit != 1)
stData.Transmit = 1;
if(stData.ClockFrequency != 80000000)
stData.ClockFrequency = 80000000;
if((nRet = SetTransferParameter(stData)) != OK)
return SET_ERROR;
if((unCurrentX != static_cast<unsigned int>(shX))
|| (unCurrentY != static_cast<unsigned int>(shY))
||(m_sptrGrabber->Get_Framebuffer() == 0))
{
if(ArmCamera() != OK)
return SET_ERROR;
if(m_sptrGrabber->Free_Framebuffer() != OK)
return SET_ERROR;
if(m_sptrGrabber->Set_Grabber_Size(shX,shY) != OK)
return SET_ERROR;
cout<<"arm camera"<<endl;
// if(m_sptrGrabber->PostArm(1) != OK )
// return SET_ERROR;
//cout<<"post arm camera"<<endl;
//check current frame grabber settings
// unsigned int unCurrentX,unCurrentY,unCurrentDepth;
if(m_sptrGrabber->PostArm(1) != OK )
// m_sptrGrabber->Get_actual_size(&unCurrentX,&unCurrentY,&unCurrentDepth);
// cout<<"get actual size"<<endl;
// if((unCurrentX != static_cast<unsigned int>(shX))
// || (unCurrentY != static_cast<unsigned int>(shY))
// ||(m_sptrGrabber->Get_Framebuffer() == 0))
// {
// cout<<"change setting"<<endl;
// if(m_sptrGrabber->Free_Framebuffer() != OK)
// return SET_ERROR;
// cout<<"change setting 1"<<endl;
// // if(m_sptrGrabber->Set_Grabber_Size(shX,shY) != OK)
// // return SET_ERROR;
cout<<"change setting 2"<<endl;
if(m_sptrGrabber->PostArm() != OK )
return SET_ERROR;
cout<<"change setting 3"<<endl;
if(m_sptrGrabber->Allocate_Framebuffer(20) != OK)
return SET_ERROR;
if(!m_vImg.empty())
m_vImg.clear();
// if(!m_vImg.empty())
// m_vImg.clear();
// m_vImg.resize(shX*shY,0);
// }
cout<<shX*shY<<endl;
if(m_vImg.size() != static_cast<size_t>(shX*shY))
m_vImg.resize(shX*shY,0);
}
//10s timeout
if(m_sptrGrabber->Set_Grabber_Timeout(10000) != OK)
return SET_ERROR;
if(SetStorageMode(1) != OK)
return SET_ERROR;
// if(SetStorageMode(1) != OK)
// return SET_ERROR;
if(ClearRAMSegment() != OK)
return SET_ERROR;
// if(ClearRAMSegment() != OK)
// return SET_ERROR;
if(SetRecordingState(1) != OK )
return SET_ERROR;
......@@ -145,8 +222,7 @@ namespace PcoNS
{
if(PreAcq() != OK)
return SET_ERROR;
//start acquisition
//start acquisition
if(m_sptrGrabber->Start_Acquire(nFrameNumbers) != OK)
return START_ERROR;
......@@ -157,7 +233,10 @@ namespace PcoNS
{
if(m_sptrGrabber->Stop_Acquire() != OK)
return STOP_ERROR;
if(SetRecordingState(0) != OK )
return SET_ERROR;
return OK;
}
......@@ -165,22 +244,30 @@ namespace PcoNS
{
int nPicNum = 1;
void* ptrAddr;
if(m_vImg.empty())
return INVALID_VALUE;
cout<<"test empty"<<endl;
short shTrig1,shTrig2;
if(GetTriggerMode(shTrig1) != OK)
return GET_ERROR;
cout<<"get trigger"<<endl;
if(shTrig1 == 0x0001)//software trigger
if(ForceTrigger(shTrig2) != OK)
return START_ERROR;
cout<<"send trigger"<<endl;
if(m_sptrGrabber->Wait_For_Next_Image(&nPicNum,10) != OK)
return RECORD_ERROR;
cout<<"wait 1"<<endl;
if(m_sptrGrabber->Check_DMA_Length(nPicNum) != OK)
return GET_ERROR;
if(m_sptrGrabber->Get_Framebuffer_adr(nPicNum,(void**)&ptrAddr) != OK)
return RECORD_ERROR;
m_sptrGrabber->Extract_Image(&m_vImg[0],ptrAddr,nX,nY);
m_sptrGrabber->Unblock_buffer(nPicNum);
vImg = m_vImg;
......
......@@ -28,30 +28,29 @@ namespace PcoNS
{
public:
Pco4000();
~Pco4000() = default;
int SetCamera(shared_ptr<CPco_com>& sptrCamera,
shared_ptr<CPco_grab_cl_me4>& sptrGraber) override;
int GetPixelRate(int& nPixelRate) override;
int SetPixelRate(int nPixelRate) override;
int GetRecorderMode(short& shRecorderMode) override;
int SetRecorderMode(short shRecorderMode) override;
int GetCoolingSetpointTemperature(short& shTemperature) override;
int SetCoolingSetpointTemperature(short shTemperature) override;
int GetCoolingSetpointTemperature(short& shTemperature);
int SetCoolingSetpointTemperature(short shTemperature);
int GetBinning(short& shBinHorz,short& shBinVert) override;
int SetBinning(short shBinHorz,short shBinVert) override;
int GetBinning(short& shBinHorz,short& shBinVert);
int SetBinning(short shBinHorz,short shBinVert);
int GetADCOperation(short& shADCNum) override;
int SetADCOperation(short shADCNum) override;
int GetADCOperation(short& shADCNum);
int SetADCOperation(short shADCNum);
int SetStorageMode(short shStorageMode);
int ClearRAMSegment();
int StartAcq(int nFrameNumbers) override;
int StartAcq(int nFrameNumbers);
int StopAcq() override;
int GetImageData(vector<short>& vImg,int& nX,int& nY) override;
int GetImageData(vector<short>& vImg,int& nX,int& nY);
private:
int PreAcq();
......
......@@ -39,6 +39,7 @@ namespace PcoNS
* @return pco product
*/
virtual unique_ptr<PcoProduct> CreateProduct() = 0;
virtual ~PcoFactory() = default;
};
/**
......
......@@ -95,7 +95,7 @@ namespace PcoNS
m_uptrPcoCamera->SetCamera(m_sptrCamera,sptrGrabber);
uptrCameraFactory.reset();
}
else if(ushCameraType == 0x1000) //pco dimax HS4 //NOT FULLY TESTED
else if(ushCameraType == 0x1000) //pco dimax HS4
{
unique_ptr<PcoFactory> uptrCameraFactory
= unique_ptr<PcoFactory>(new PcoDimaxHS4Factory());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment