#include "Thread.h" #include "radioGroup.h" #include "runtime.h" #include #include "CCD.h" #include "Atmcd32d.h" #include #include #include "scanner.h" #include "CCDControl.h" #include "DLL6K.h" #include "grating_focus.h" #include "FISS.h" #include "scanner.h" #include #include "Mmsystem.h" #include //#pragma comment(lib, "winmm.lib"); WORD timeget1, timeget2; char strt[30]; extern int take; extern int Scanpos_CCDframe; //panel °ü·Ã º¯¼ö extern int mainPanel; //HANDLE OF MAIN PANEL(¸ÞÀÎ ÆгÎÀÇ ÇÚµé) extern int FISSpanelSetting; extern int testpanel; extern int TabPanelHandle; //handle of tab panel extern int aboutPanel; extern int menubar; extern int GraphicPanel; extern int temp_thread, temp_thread_id; int Run_thread_stop=1; //1: stop extern long nCameraHandle1; //camera handle1 extern long nCameraHandle2; //camera handle2 extern LARGE_INTEGER gliFreq, gliStart, gliEnd; extern WORD* g_pRawData; //allocated data dumped real data extern WORD* g_pRawData2; //allocated data dumped real data extern int nhDim1,nvDim1,nhDim2,nvDim2; extern int CCD_status; extern int Scanner_status; extern int g_nFrameNumber1;//, g_nNumberKinetics1; extern int ccd_camera; extern int sequential_number; extern float g_fExpTime1, g_fExpTime2; //exposure time extern char entire_directory[250]; extern int fiss_take_mode; extern int Scanner_InPosition; extern float scanpos; extern WvSet Data[50]; extern float *flatdata1, *flatdata2; extern float *flatcube1, *flatcube2; extern WORD* BiasDark1; extern WORD* BiasDark2; extern int DataSource; extern long nUnknownCameraHandle; extern int temp_warming; int program_off_temp_set=0; int CVICALLBACK setTempThread(void* functionData) { int errorValue1,errorValue2; int CCDTemp1, CCDTemp2; int i=0; char buffer[100]; char CCDTempStr[100]; SetCtrlVal(mainPanel,PANEL_CCDTEMPSTATUS, 0); while(!temp_thread) { SetCurrentCamera(nCameraHandle1); errorValue1=GetTemperature(&CCDTemp1); SetCurrentCamera(nCameraHandle2); errorValue2=GetTemperature(&CCDTemp2); if((errorValue1!=DRV_TEMP_STABILIZED) || (errorValue2!=DRV_TEMP_STABILIZED)) { Delay(1); SetCurrentCamera(nCameraHandle1); errorValue1=GetTemperature(&CCDTemp1); SetCurrentCamera(nCameraHandle2); errorValue2=GetTemperature(&CCDTemp2); sprintf(buffer,"CCD1: %d C CCD2: %d C\n", CCDTemp1,CCDTemp2); //SetCtrlVal(mainPanel, PANEL_TB_Text_Monitor,buffer); SetCtrlVal(testpanel, test_panel_TB_Text_Monitor,buffer); sprintf(CCDTempStr, "%d %cC", CCDTemp1,176); SetCtrlVal(mainPanel, PANEL_CCD1TEMP,CCDTempStr); sprintf(CCDTempStr, "%d %cC", CCDTemp2, 176); SetCtrlVal(mainPanel, PANEL_CCD2TEMP,CCDTempStr); } else { SetCtrlVal(mainPanel, PANEL_TB_Text_Monitor,"Temperature Stabilized!\n"); SetCtrlVal(testpanel, test_panel_TB_Text_Monitor,"Temperature Stabilized!\n"); SetCtrlVal(mainPanel,PANEL_CCDTEMPSTATUS, 1); temp_thread=1; } if(temp_warming==1){ sprintf(buffer,"Now in the loop temp_warming=1"); SetCtrlVal(testpanel, test_panel_TB_Text_Monitor,buffer); if((CCDTemp1 >5) && (CCDTemp2 >5)) { temp_thread=1; temp_warming=0; } } } return 0; } int CVICALLBACK RunThread(void* functionData) { int i; char temp[50],temp1[50],temp2[50],temp3[50],temp4[50]; unsigned short minvalue,maxvalue; int ccd_acqmode; //ccd acquisition mode(single, video, frame transfer) float diff_time1,diff_time2; int ii,j,k,startpoint1,startpoint2; int flatstart1,flatstart2; int id,handle; int threadfunctionID; float difftime; int attr_top, attr_width, attr_left; SetCtrlAttribute(mainPanel, PANEL_viewCCD1,ATTR_DIMMED,1); SetCtrlAttribute(mainPanel, PANEL_viewCCD2,ATTR_DIMMED,1); Run_thread_stop=0; if ((GraphicPanel = LoadPanel (0, "FISS.uir", GRAPHICPNL)) < 0) return -1; GetPanelAttribute(mainPanel, ATTR_TOP, &attr_top); GetPanelAttribute(mainPanel, ATTR_WIDTH, &attr_width); GetPanelAttribute(mainPanel, ATTR_LEFT, &attr_left); SetPanelAttribute(GraphicPanel, ATTR_TOP, attr_top); SetPanelAttribute(GraphicPanel, ATTR_LEFT, attr_left+attr_width+7); DisplayPanel(GraphicPanel); GetPanelHandleFromTabPage(FISSpanelSetting, SetFISS_setTAB, 0, &TabPanelHandle); GetCtrlVal(TabPanelHandle, setCCDTAB_CCD_setAcq, &ccd_acqmode); if(!QueryPerformanceFrequency(&gliFreq)) MessagePopup("Error","Cannot support the timer of high resolution"); SetCtrlAttribute(mainPanel, PANEL_viewCCD1,ATTR_DIMMED,1); SetCtrlAttribute(mainPanel, PANEL_viewCCD2,ATTR_DIMMED,1); SetCtrlAttribute(mainPanel, PANEL_SelectAxis, ATTR_DIMMED,1); SetCtrlAttribute(mainPanel, PANEL_set_Select_Frame, ATTR_DIMMED,1); SetCtrlAttribute(mainPanel, PANEL_BYTSCL_MIN, ATTR_DIMMED,1); SetCtrlAttribute(mainPanel, PANEL_BYTSCL_MAX, ATTR_DIMMED,1); SetCtrlAttribute(mainPanel, PANEL_GRAPH, ATTR_DIMMED,1); if(g_nFrameNumber1==1) //single mode , Âï´Â ÇÁ·¹ÀÓÀÌ ´ÜÁö 1ÀÏ °æ¿ì. { //´Ü¼øÇÑ single mode if(ccd_camera==2 || ccd_camera==3) //both mode { for(i=0;i1) && (ccd_acqmode!=6) &&(ccd_acqmode!=8)) //½ÇÁúÀûÀ¸·Î CCD¿Í Scanner°¡ ¿¬µ¿µÇ¾î¼­ ¿òÁ÷¿©Áö´Â ºÎºÐ. { if(ccd_camera==2) //both mode, sequentially operate e.g scanning-CCD1 complete-->scanning-CCD2 complete { for(i=0;i-1) && (Scanner_InPosition==1))) ; marktime_start(temp1); SetCurrentCamera(nCameraHandle1); ExecuteProgram(nCameraHandle1,0); marktime_end(temp2); diff_time1=time_difference(); do { }while(!((scanpos<1) && (scanpos>-1) && (Scanner_InPosition==1))) ; marktime_start(temp3); SetCurrentCamera(nCameraHandle2); ExecuteProgram(nCameraHandle2,0); marktime_end(temp4); diff_time2=time_difference(); SaveFits(nhDim1, nvDim1, g_nFrameNumber1, g_fExpTime1, nCameraHandle1, temp1, temp2, diff_time1, entire_directory); SaveFits(nhDim2, nvDim2, g_nFrameNumber1, g_fExpTime2, nCameraHandle2, temp3, temp4, diff_time2, entire_directory); SetCurrentCamera(nCameraHandle1); Radio_SetMarkedOption(mainPanel, PANEL_SelectAxis, 0); Display3D_CCD(1,nhDim1/2,&minvalue,&maxvalue,nCameraHandle1); timeget2=timeGetTime(); sprintf(strt,"%.1f",(float)(timeget2-timeget1)*0.001); SetCtrlVal(mainPanel, PANEL_info10,strt); } //after for loop, present image. SetCurrentCamera(nCameraHandle1); DisplayCCDImage(nhDim1, nvDim1, g_nFrameNumber1, nCameraHandle1); SetCtrlVal(mainPanel, PANEL_viewCCD1,1); SetCtrlVal(mainPanel, PANEL_viewCCD2,0); SetCtrlAttribute(mainPanel, PANEL_viewCCD1,ATTR_DIMMED,0); SetCtrlAttribute(mainPanel, PANEL_viewCCD2,ATTR_DIMMED,0); } else if(ccd_camera==3) //both mode that we must use { for(i=0;i-1) && (Scanner_InPosition==1))) ; marktime_start(temp1); ExecuteProgram(nCameraHandle1,1); marktime_end(temp2); diff_time1=time_difference(); SaveFits(nhDim1, nvDim1, g_nFrameNumber1, g_fExpTime1, nCameraHandle1, temp1, temp2, diff_time1, entire_directory); SaveFits(nhDim2, nvDim2, g_nFrameNumber1, g_fExpTime2, nCameraHandle2, temp1, temp2, diff_time1, entire_directory); SetCurrentCamera(nCameraHandle1); Radio_SetMarkedOption(mainPanel, PANEL_SelectAxis, 0); //Display3D_CCD(1,nhDim1/2,&minvalue,&maxvalue,nCameraHandle1); Display3D_CCD(1,260,&minvalue,&maxvalue,nCameraHandle1); timeget2=timeGetTime(); difftime=((float)timeget2-(float)timeget1)*0.001; if(difftime>0)sprintf(strt,"%.1f",difftime); SetCtrlVal(mainPanel, PANEL_info10,strt); } SetCurrentCamera(nCameraHandle1); DisplayCCDImage(nhDim1, nvDim1, g_nFrameNumber1, nCameraHandle1); SetCtrlVal(mainPanel, PANEL_viewCCD1,1); SetCtrlVal(mainPanel, PANEL_viewCCD2,0); SetCtrlAttribute(mainPanel, PANEL_viewCCD1,ATTR_DIMMED,0); SetCtrlAttribute(mainPanel, PANEL_viewCCD2,ATTR_DIMMED,0); } else if(ccd_camera==0) //ccd1,nCameraHandle1 //single camera { fiss_take_mode=0; SetCurrentCamera(nCameraHandle1); for(i=0;i-1) && (Scanner_InPosition==1))) ; marktime_start(temp1); ExecuteProgram(nCameraHandle1,0); marktime_end(temp2); diff_time1=time_difference(); SaveFits(nhDim1, nvDim1, g_nFrameNumber1, g_fExpTime1, nCameraHandle1, temp1, temp2, diff_time1, entire_directory); Display3D_CCD(1,nhDim1/2,&minvalue,&maxvalue, nCameraHandle1); timeget2=timeGetTime(); sprintf(strt,"%.1f",(float)(timeget2-timeget1)*0.001); SetCtrlVal(mainPanel, PANEL_info10,strt); } Radio_SetMarkedOption(mainPanel, PANEL_SelectAxis, 0); DisplayCCDImage(nhDim1, nvDim1, g_nFrameNumber1, nCameraHandle1); SetCurrentCamera(nCameraHandle1); SetCtrlVal(mainPanel, PANEL_viewCCD1, 1); SetCtrlVal(mainPanel, PANEL_viewCCD2, 0); SetCtrlAttribute(mainPanel, PANEL_viewCCD1,ATTR_DIMMED,0); SetCtrlAttribute(mainPanel, PANEL_viewCCD2,ATTR_DIMMED,1); } else if(ccd_camera==1) //ccd2, nCameraHandle2 { fiss_take_mode=0; SetCurrentCamera(nCameraHandle2); for(i=0;i-1) && (Scanner_InPosition==1))) ; marktime_start(temp1); ExecuteProgram(nCameraHandle2,0); marktime_end(temp2); diff_time1=time_difference(); SaveFits(nhDim2, nvDim2, g_nFrameNumber1, g_fExpTime2, nCameraHandle2, temp1, temp2, diff_time1, entire_directory); Display3D_CCD(1,nhDim2/2,&minvalue,&maxvalue, nCameraHandle2); timeget2=timeGetTime(); sprintf(strt,"%.1f",(float)(timeget2-timeget1)*0.001); SetCtrlVal(mainPanel, PANEL_info10,strt); } Radio_SetMarkedOption(mainPanel, PANEL_SelectAxis, 0); DisplayCCDImage(nhDim2, nvDim2, g_nFrameNumber1, nCameraHandle2); SetCurrentCamera(nCameraHandle2); SetCtrlVal(mainPanel, PANEL_viewCCD1, 0); SetCtrlVal(mainPanel, PANEL_viewCCD2, 1); SetCtrlAttribute(mainPanel, PANEL_viewCCD1,ATTR_DIMMED,1); SetCtrlAttribute(mainPanel, PANEL_viewCCD2,ATTR_DIMMED,0); } else if(ccd_camera==4) //flat fileding, important!!! --> move to CCD.c (TakingFlat) { MessagePopup("","Error"); } SetCtrlAttribute(mainPanel, PANEL_set_Select_Frame, ATTR_DIMMED, 0); //undim Frame Slide SetCtrlAttribute(mainPanel, PANEL_SelectAxis, ATTR_DIMMED, 0); //undim Frame Slide SetCtrlAttribute(mainPanel, PANEL_set_Select_Frame, ATTR_MIN_VALUE, 0); SetCtrlAttribute(mainPanel, PANEL_set_Select_Frame, ATTR_MAX_VALUE, g_nFrameNumber1-1); SetCtrlVal(mainPanel, PANEL_set_Select_Frame, 0); } if((g_nFrameNumber1 >1) && (ccd_acqmode==6)) //frame transfer mode { for(i=0;i1) && (ccd_acqmode==8)) //scan stop, operate only CCD at fix position { //printf("scan stop mode!!!\n"); //PmacAccessible=0; //turn off MonitoringThread Function //////////////// /* if(ccd_camera==2) //both mode, sequentially operate e.g scanning-CCD1 complete-->scanning-CCD2 complete { for(i=0;i-1) && (Scanner_InPosition==1))) ; marktime_start(temp1); SetCurrentCamera(nCameraHandle1); for(j=0;j-1) && (Scanner_InPosition==1))) ; marktime_start(temp3); SetCurrentCamera(nCameraHandle2); for(j=0;j-1) && (Scanner_InPosition==1))) ; marktime_start(temp1); //SetCurrentCamera(nCameraHandle1); for(j=0;j-1) && (Scanner_InPosition==1))) ; marktime_start(temp1); for(j=0;j move to CCD.c (TakingFlat) { MessagePopup("","Error"); } */ SetCtrlAttribute(mainPanel, PANEL_set_Select_Frame, ATTR_DIMMED, 0); //undim Frame Slide SetCtrlAttribute(mainPanel, PANEL_SelectAxis, ATTR_DIMMED, 0); //undim Frame Slide SetCtrlAttribute(mainPanel, PANEL_set_Select_Frame, ATTR_MIN_VALUE, 0); SetCtrlAttribute(mainPanel, PANEL_set_Select_Frame, ATTR_MAX_VALUE, g_nFrameNumber1-1); SetCtrlVal(mainPanel, PANEL_set_Select_Frame, 0); //////////////// } DataSource=1; //PmacAccessible=1; Run_thread_stop=1; DiscardPanel(GraphicPanel); GraphicPanel=0; return 0; } void CVICALLBACK AfterRunThread(int poolHandle, int functionID, unsigned int event, int value, void *callbackData) { }