/***************************************************************************** - - - POLONY SEQUENCER ACQUISITION SUITE - - Church Lab - - Harvard Medical School - - - - Free software for running a Polony Sequencing automated microscope - - - - ========================================================================= - - - - - - cscope.h - - - - Interface class to Nikon TE2000 - - - - Written by Michelle Kuykendal, 08-10-2005 - - - - Revised - - 02-15-2006 GP; fixed filter cube functions and added Uniblitz trigger - - - - 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: cscope.h **** **** Requirements: cscope.cpp and cport.h should exist in the same **** **** directory as this file. **** **** Purpose: this file defines the CScope class to be used with a **** **** Nikon Eclipse TE2000-E microscope. it enables the user of the CScope **** **** class to set, confirm and get the scope position, to set and get the **** **** filter block changover address, and to initialize and close the **** **** scope. it also provides functions to write to and read from the **** **** scope via the comm port to enable the addition of new functions in **** **** the future. **** **** Initial Version: Aug. 10, 2005 **** **** Programmer: Michelle Kuykendal **** ******************************************************************************* ******************************************************************************/ #ifndef CSCOPE_H #define CSCOPE_H #include #include //input and output functionality #include "cport.h" //serial port class #include "reporter.h" class CScope { public: CScope(Reporter*); ~CScope(); bool SetPosition(double z); bool ConfirmPosition(); bool SetFilterBlock(int addr); char *GetFilterBlock(); bool Init(); bool Close(); double GetPos(); bool OpenUniblitz(); bool CloseUniblitz(); private: //scope serial port object for reading and writing to COM3 CPort PortScope; //boolean variable to be updated to "true" when the scope is initalized // or to "false" when the scope is closed bool scopeIsInit; //char * variable to hold the expected response from a read call char Response[40]; //after a call to GetPosition(), this char * variable will hold the z // position of the scope if the return is true. it will hold the string, // "Could not get scope position." if the return is false. char zPos[40]; //after a call to GetFilterBlock(), this char * variable will hold the // address of the block if the return is true. it will hold the string, // "Could not get block position." if the return is false. char blockAddr[40]; //zmin and zmax are set during construction int zmin; //zmin = 0 int zmax; //zmax = 200,000 int addrmin;//addrmin = 1 int addrmax;//addrmax = 6 //the time allowed to pass (by checking the system clock) while looping to // look for a read string. int tTimeOut; //REQUIREMENTS: a call to Init() should be made prior to this call for // proper execution, however, a failure will not occur otherwise. //USE: WriteScope() will check to see that the scope was first intialized. // it will then write the passed string to the comm port that was opened // during the call to Init(). while the write has not completed (known // because mResWrite, the result of the write, will be false) the function // will continuously check for completion. NOTE: the WriteCPort() command // will only return false if an error occurs. the return value of the // function should not be used to determine if the write was completed. // the return value should only be used to confirm that an error did or did // not occur. if the write command was executed, but the write was not // immediately completed, it will return false and the mResWrite variable // will remain false. if the write was immediately completed, the mResWrite // variable will be true. //RETURN VALUE: the return will be false if the scope has not been first // initialized or the WriteCPort() call returned false due to an error. the // return will be true if the scope is already intialized and the write is // successful. bool WriteScope(char *ToWrite); //REQUIREMENTS: a call to Init() should be made prior to this call for // proper execution, however, a failure will not occur otherwise. the // mBytesToRead parameter of the comm port should first be designated // by the command PortScope.mBytesToRead = num; where num is the number // of bytes to be read. the Response string should first be set to the // string that is expected to be read from the scope. if it is not first // set, the function will return false. //USE: ReadScope() will check to see that the scope was first intialized. // it will then read from the comm port that was opened during the call // to Init() in byte chunks of a size that was designated by the parameter // mBytesToRead. while the read has not completed (known because mResRead, // the result of the read, will be false) the function will continuously // check for completion. it will then compare the read string to the // expected Response string. NOTE: the WriteCPort() command will only // return false if an error occurs. the return value of the function should // not be used to determine if the read was completed. the return value // should only be used to confirm that an error did or did not occur. if // the read command was executed, but the read was not immediately // completed, it will return false and the mResRead variable will remain // false. if the read was immediately completed, the mResRead variable // will be true. //RETURN VALUE: the return will be false if the scope has not been first // initialized, the ReadCPort() call returned false due to an error, or // because the string read was not the same as the Response string. the // return will be true if the scope is already intialized and if what is // read is the same as the Response string bool ReadScope(); Reporter* r; }; #endif