/***************************************************************************** - - - POLONY SEQUENCER ACQUISITION SUITE - - Church Lab - - Harvard Medical School - - - - Free software for running a Polony Sequencing automated microscope - - - - ========================================================================= - - - - - - cpifoc.cpp - - - - Interface class to Physik Instrumente Pifoc controller API - - - - Written by Greg Porreca, 02-15-2006 - - - - Revised - - - - - - This software may be used, modified, and distributed freely, but this - - header may not be modified and must appear at the top of this file. - - - - - *****************************************************************************/ /****************************************************************************** ******************************************************************************* **** File: CPifoc.cpp **** ******************************************************************************/ #include "CPifoc.h" #include "E816_DLL.h" #include #define TRUE 1 #define FALSE 0 #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #define nPortNr 1 #define BaudRate 115200 #define szAxes "A" CPifoc::CPifoc(Reporter* rep){ r = rep; } CPifoc::~CPifoc(){ } bool CPifoc::Init() { pbValarray = 1; const int ID = E816_ConnectRS232(nPortNr, BaudRate); if(ID==-1){ fprintf(stderr, "ERROR: pifoc is not responding on COM%d at baud = %ld\n", nPortNr, BaudRate); return 0; } if(E816_SVO(ID, szAxes, &pbValarray)==0){ fprintf(stderr, "Unable to set servo on for pifoc.\n"); } return 1; } void CPifoc::Close() { E816_CloseConnection(ID); } bool CPifoc::SetPosition(double z){ // fprintf(stderr, "setpos about to command the pifoc. press enter.\n"); // while(!(getc(stdin))){;} if(E816_MOV(ID, szAxes, &z) == 0){ fprintf(stderr, "ERROR (CPifoc:SetPosition()) command MOV not responding\n"); fprintf(stderr, "ERROR %d returned.\n", E816_GetError(ID)); return 0; } return 1; } bool CPifoc::SetPositionRelative(double z){ if(E816_MVR(ID, szAxes, &z) == 0){ fprintf(stderr, "ERROR (CPifoc:SetPosition()) command MVR not responding\n"); fprintf(stderr, "ERROR %d returned.\n", E816_GetError(ID)); return 0; } return 1; } bool CPifoc::ConfirmPosition(){ //fprintf(stderr, "confirmpos about to command the pifoc. press enter.\n"); //while(!(getc(stdin))){;} if(E816_qONT(ID, szAxes, &pbOnTarget)==0){ fprintf(stderr, "ERROR (CPifoc:ConfirmPosition()) command qONT not responding\n"); fprintf(stderr, "ERROR %d returned.\n", E816_GetError(ID)); return false; } if(pbOnTarget == 1){ return true; } else{ return false; } } double CPifoc::GetPos(){ // fprintf(stderr, "getpos about to command the pifoc. press enter.\n"); // while(!(getc(stdin))){;} if(E816_qPOS(ID, szAxes, &currPos) == 0){ fprintf(stderr, "ERROR (CPifoc:GetPos()) command qPOS not responding\n"); fprintf(stderr, "ERROR %d returned.\n", E816_GetError(ID)); return 0; } return currPos; }