void TestPVCAM(CMMCore& core)
{
   unsigned height = core.getImageHeight();
   unsigned width = core.getImageWidth();

   //cout << "Setting bin size 4..." << endl;
   //core.setProperty("Camera", "Binning", "4");
   //height = core.getImageHeight();
   //width = core.getImageWidth();
   //core.snapImage();

   //cout << "Setting bin size 2..." << endl;
   //core.setProperty("Camera", "Binning", "2");
   //height = core.getImageHeight();
   //width = core.getImageWidth();
   //core.snapImage();

   cout << "Setting bin size 1..." << endl;
   core.setProperty("Camera", "Binning", "1");
   height = core.getImageHeight();
   width = core.getImageWidth();
   core.setExposure(1);

   unsigned char* pBuf = new unsigned char[core.getImageBufferSize()];
   long startT = GetTickCount();
   core.snapImage();
   long endT = GetTickCount() - startT;
   cout << "snapImage() took " << endT << " ms" << endl;
   startT = GetTickCount();
   void* pCamBuf = core.getImage();
   memcpy(pBuf, pCamBuf, core.getImageBufferSize());
   endT = GetTickCount() - startT;
   cout << "getImage() took " << endT << " ms" << endl;
   delete[] pBuf;
}
void TestColorMode(CMMCore& core)
{
   string camera = core.getCameraDevice();
   core.setProperty(camera.c_str(), "ColorMode", "RGB-32bit");
   core.snapImage();
   core.getRGB32Image();
   cout << "image: " << core.getImageWidth() << " X " << core.getImageHeight() << " X " << core.getNumberOfChannels() << endl;
}
void LoadZeissMTB(CMMCore& core)
{
   core.unloadAllDevices();

   // load devices
   // ------------
   cout << "Loading devices..." << endl;

   core.loadDevice("REFLECTOR", "ZeissMTB", "Reflector");
   core.loadDevice("Z", "ZeissMTB", "Focus");
   core.loadDevice("SHUTTER", "ZeissMTB", "Shutter");
   core.loadDevice("OBJECTIVE", "ZeissMTB", "Objective");
   core.loadDevice("LAMP", "ZeissMTB", "Halogen");
   core.initializeAllDevices();

}
void TestPixelSize(CMMCore& core)
{
   core.definePixelSizeConfig("Resolution10", "Objective", "State", "1");
   core.definePixelSizeConfig("Resolution20", "Objective", "State", "3");
   core.definePixelSizeConfig("Resolution40", "Objective", "State", "0");
   core.setPixelSizeUm("Resolution10", 1.0);
   core.setPixelSizeUm("Resolution20", 0.5);
   core.setPixelSizeUm("Resolution40", 0.25);

   core.setState("Objective", 2);
   cout << "Pixel size = " << core.getPixelSizeUm() << " um" << endl;

   core.setState("Objective", 1);
   cout << "Pixel size = " << core.getPixelSizeUm() << " um" << endl;

   core.setState("Objective", 3);
   cout << "Pixel size = " << core.getPixelSizeUm() << " um" << endl;

   core.setState("Objective", 0);
   cout << "Pixel size = " << core.getPixelSizeUm() << " um" << endl;

}
/**
 * Test routine for the MMConfig_Stream.cfg.
 */
void TestCameraStreaming(CMMCore& core)
{
   const long numFrames = 20;
   const int memoryFootprintMB = 100;
   const double intervalMs = 300.0; // ms
   ACE_Time_Value displayTime(0, 80000L); // us
   ACE_Time_Value restTime(5, 0L);


   core.setCircularBufferMemoryFootprint(memoryFootprintMB);

   cout << "Buffer capacity: " << core.getBufferTotalCapacity() << endl;
   string camera = core.getCameraDevice();
   //core.setProperty(camera.c_str(), "ShutterMode", "Open");
   //core.setProperty(camera.c_str(), "Binning", "2");
   core.setExposure(200.0);

   // test normal mode
   core.snapImage();
   core.getImage();

   core.startSequenceAcquisition(numFrames, intervalMs);

   StreamTask streamWriter(&core);
   int result = streamWriter.activate ();

   int count=0;
   while (core.deviceBusy(camera.c_str()))
   {
      core.getLastImage();
      double interval = core.getBufferIntervalMs();
      printf("Displaying current image, %ld in que, %.0f ms interval.\n", core.getRemainingImageCount(), interval);
      ACE_OS::sleep(displayTime);
   }
   printf("Camera finished with %.0f ms interval.\n", core.getBufferIntervalMs());
   core.setProperty(camera.c_str(), "ShutterMode", "Auto");

   
   streamWriter.wait ();

   cout << "Done! Free space =" << core.getBufferFreeCapacity() << endl;

   core.startSequenceAcquisition(numFrames, intervalMs);

   StreamTask streamWriter1(&core);
   result = streamWriter1.activate ();

   count=0;
   while (core.deviceBusy(camera.c_str()))
   {
      core.getLastImage();
      double interval = core.getBufferIntervalMs();
      printf("Displaying current image, %ld in que, %.0f ms interval.\n", core.getRemainingImageCount(), interval);
      ACE_OS::sleep(displayTime);
   }
   printf("Camera finished with %.0f ms interval.\n", core.getBufferIntervalMs());
   core.setProperty(camera.c_str(), "ShutterMode", "Auto");

   
   streamWriter1.wait ();
}
/**
 * Test routine for the MMConfig_Demo.cfg.
 * Device names must match
 */
void TestDemoDevices(CMMCore& core)
{
   const char* XYStageName = "XYStage";
   const char* wheelName = "Emission";

   // Example 1: move filter wheel to state(position) 3
   // -------------------------------------------------
   core.setState(wheelName, 3);
   core.waitForDevice(wheelName);

   long state = core.getState(wheelName);
   cout << "State device " << wheelName << " in state " << state << endl;

   // Example 2: move filter wheel to specific label (must be previously defined)
   // ---------------------------------------------------------------------------
   core.setStateLabel(wheelName, "Chroma-HQ620");
   core.waitForDevice(wheelName);

   state = core.getState(wheelName);
   string stateLabel = core.getStateLabel(wheelName);
   cout << "State device " << wheelName << " in state " << state << ", labeled as " << stateLabel << endl;

   // Example 3: move multiple filters at once using one of the predefined configurations
   // -----------------------------------------------------------------------------------
   core.setConfig("Channel", "DAPI");
   core.waitForSystem();

   // print current status for all state devices
   vector<string> stateDevices = core.getLoadedDevicesOfType(MM::StateDevice);
   for (size_t i=0; i<stateDevices.size(); i++)
   {
      state = core.getState(stateDevices[i].c_str());
      stateLabel = core.getStateLabel(stateDevices[i].c_str());
      cout << "State device " << stateDevices[i] << " in state " << state << ", labeled as " << stateLabel << endl;
   }

   // Example 4: snap an image
   // ------------------------
   core.setExposure(100.0);
   core.setProperty("Camera", "PixelType", "8bit");
   core.snapImage();
   cout << "Image snapped." << endl;

   // Example 5: move XYStage
   // -----------------------
   core.setXYPosition(XYStageName, 0.0, 0.0);
   core.waitForDevice(XYStageName);

   core.setXYPosition(XYStageName, 10000.0, 10000.0);
   core.waitForDevice(XYStageName);

   double x,y;
   core.getXYPosition(XYStageName, x, y);
   
   cout << "XY position = " << x << "," << y << endl;
}
void TestPCO(CMMCore& core)
{
   unsigned height = core.getImageHeight();
   unsigned width = core.getImageWidth();

   //cout << "Setting bin size 4..." << endl;
   //core.setProperty("Camera", "Binning", "4");
   //height = core.getImageHeight();
   //width = core.getImageWidth();
   //core.snapImage();

   //cout << "Setting bin size 2..." << endl;
   //core.setProperty("Camera", "Binning", "2");
   //height = core.getImageHeight();
   //width = core.getImageWidth();
   //core.snapImage();

   cout << "Setting bin size 1..." << endl;
   core.setProperty("CAM", "Binning", "1");

   cout << "Setting ROI..." << endl;
   core.setROI(101, 267, 333, 674);
  // core.setROI(100, 100, 100, 100);
  unsigned x, y, xSize, ySize;
  core.getROI(x, y, xSize, ySize);
  cout << "ROI set to:" << x << ", " << y << ", " << xSize << ", " << ySize << endl;

   height = core.getImageHeight();
   width = core.getImageWidth();
   core.setExposure(1);

   unsigned char* pBuf = new unsigned char[core.getImageBufferSize()];
   long startT = GetTickCount();
   core.snapImage();
   long endT = GetTickCount() - startT;
   cout << "snapImage() took " << endT << " ms" << endl;
   startT = GetTickCount();
   void* pCamBuf = core.getImage();
   memcpy(pBuf, pCamBuf, core.getImageBufferSize());
   endT = GetTickCount() - startT;
   cout << "getImage() took " << endT << " ms" << endl;
   delete[] pBuf;

   cout << "Clearing ROI..." << endl;
   core.clearROI();
  core.getROI(x, y, xSize, ySize);
  cout << "ROI set to:" << x << ", " << y << ", " << xSize << ", " << ySize << endl;

   height = core.getImageHeight();
   width = core.getImageWidth();
   core.setExposure(1);

   pBuf = new unsigned char[core.getImageBufferSize()];
   startT = GetTickCount();
   core.snapImage();
   endT = GetTickCount() - startT;
   cout << "snapImage() took " << endT << " ms" << endl;
   startT = GetTickCount();
   pCamBuf = core.getImage();
   memcpy(pBuf, pCamBuf, core.getImageBufferSize());
   endT = GetTickCount() - startT;
   cout << "getImage() took " << endT << " ms" << endl;
   delete[] pBuf;

}
/**
 * Creates MMCore objects loads demo device and displays the status.
 */
int main(int /* argc */, char** /*argv[]*/)
{
   try {

      // Create MMCore     
      CMMCore core;

      // load demo devices
     //LoadDemoDevices(core);
	  //core.loadSystemConfiguration("C:/projects/MicroManage/bin/MMConfig_uberzeiss.cfg");
	  //core.loadSystemConfiguration("C:/projects/MicroManage/bin/MMConfig_PVCAM.cfg");
	  core.loadSystemConfiguration("MMConfig_demo.cfg");  
	  //core.loadSystemConfiguration("C:/projects/MicroManage/bin/MMConfig_uberzeiss.cfg");
	  //core.loadSystemConfiguration("C:/projects/MicroManage/bin/MMConfig_PCO.cfg");
	  
     //LoadZeissMTB(core);
     core.enableStderrLog(false); // supress console echo of log/debug messages
   
      // print loaded equipment attributes
      vector<string> blks = core.getAvailablePropertyBlocks();
      cout << "Dumping property blocks: " << endl;
      for (size_t i=0; i<blks.size(); i++)
      {
         PropertyBlock blk = core.getPropertyBlockData(blks[i].c_str());
         cout << blks[i].c_str() << endl;
     
         for (size_t j=0; j<blk.size(); j++)
         {
            PropertyPair p = blk.getPair(j);
            cout << "   " << p.getPropertyName() << " = " << p.getPropertyValue() << endl;
         }
      }

      // print current device status
      vector<string> devices = core.getLoadedDevices();
      for (size_t i=0; i<devices.size(); i++)
      {
         cout << devices[i] << endl;
         vector<string> props = core.getDevicePropertyNames(devices[i].c_str());
         for (size_t j=0; j<props.size(); j++)
         {
            string val = core.getProperty(devices[i].c_str(), props[j].c_str());
            cout << "    " << props[j] << "=" << val << endl;
         }
      }
	
	  TestDemoDevices(core);
	  //TestZeissMTB(core);
     //TestPVCAM(core);
     //TestHam(core);
     //TestHam(core);
#ifdef WIN32
	  TestPCO(core);
#endif

	  core.unloadAllDevices();
   }
   catch (CMMError& err)
   {
      cout << "Exception: " << err.getMsg() << endl;
      cout << "Exiting now." << endl;
      return 1;
   }

   cout << "Test_MMCore ended OK." << endl;
   return 0;
}
/**
* Test routine for the MMConfig_Demo.cfg.
*/
void TestCameraLive(CMMCore& core)
{
   const int memoryFootprintMB = 100;

   core.setCircularBufferMemoryFootprint(memoryFootprintMB);

   cout << "Buffer capacity: " << core.getBufferTotalCapacity() << endl;
   string camera = core.getCameraDevice();
   //core.setProperty(camera.c_str(), "ShutterMode", "Open");
   core.setProperty(camera.c_str(), "Binning", "4");
   core.setExposure(200.0);

   // test normal mode
   core.snapImage();
   core.getImage();

   core.startContinuousSequenceAcquisition(0);

   int count=0;
   while (core.deviceBusy(camera.c_str()))
   {
      core.getLastImage();
      double interval = core.getBufferIntervalMs();
      printf("Displaying image %d, %ld in que, %.0f ms interval.\n", count+1, core.getRemainingImageCount(), interval);
      count++;
      if (count >= 100)
         core.stopSequenceAcquisition();
   }
   printf("Camera finished with %.0f ms interval.\n", core.getBufferIntervalMs());
   //core.setProperty(camera.c_str(), "ShutterMode", "Auto");

}
void TestZeissMTB(CMMCore& core)
{
   core.setProperty("Stand", "LightManager", "0");

   // exercise the system
   const char* channel = "FilterCube";
   const char* focus = "Z";
   cout << "Exercising the filter wheel..." << endl;
   vector<string> labels = core.getAllowedPropertyValues(channel, "Label");
   for (size_t i=0; i<labels.size(); i++)
   {
      cout << "Setting label " << labels[i] << endl;
      core.setProperty(channel, "Label", labels[i].c_str());
      core.waitForSystem();
      string newLabel = core.getProperty(channel, "Label");
      cout << "Label " << newLabel << " set." << endl;
   }

   // test for the reflector devices
   long state = 0;
   cout << "Testing state " << state << "..." << endl;
   core.setState(channel, state);
   core.waitForSystem();
   long pos = core.getState(channel);
   string label = core.getStateLabel(channel);
   cout << "state=" << pos << ", label=" << label << endl;
   
   state = 1;
   cout << "Testing state " << state << "..." << endl;
   core.setState(channel, state);
   core.waitForSystem();//("REFLECTOR");
   pos = core.getState(channel);
   label = core.getStateLabel(channel);
   cout << "state=" << pos << ", label=" << label << endl;

   // test the focus stage
   cout << "Testing focus..." << endl;
   cout << "z = " << core.getPosition(focus) << endl;
   core.setPosition(focus, core.getPosition(focus) + 5.0);
   core.waitForDevice(focus);
   cout << "new z = " << core.getPosition(focus) << endl;

   // test the lamp
   cout << "Testing lamp..." << endl;
   cout << "Initial state = " << core.getProperty("HalogenLamp", "OnOff") << endl;
   core.setProperty("HalogenLamp", "OnOff", "1");
   //core.sleep(500);
   cout << "State after ON = " << core.getProperty("HalogenLamp", "OnOff") << endl;
   core.setProperty("HalogenLamp", "OnOff", "0");
   cout << "State after OFF = " << core.getProperty("HalogenLamp", "OnOff") << endl;

   // test channel configs
   const char* channelGroup = "Channel";
   cout << "Testing channel configurations..." << endl;
   core.setProperty("Shutter", "State", "1");
   vector<string> configs = core.getAvailableConfigs(channelGroup);
   for (size_t i=0; i<configs.size(); i++)
   {
      core.setConfig(channelGroup, configs[i].c_str());
      //core.waitForConfig(channelGroup, configs[i].c_str());
      core.waitForSystem();
      cout << "Channel configuration applied: " << core.getCurrentConfig(channelGroup) << endl;
      core.sleep(2000);
   }
}
/**
 * Configuration routine for demo devices.
 */
void LoadDemoDevices(CMMCore& core)
{
   core.unloadAllDevices();

   // define available equipment attributes
   // -------------------------------------
   core.definePropertyBlock("Nikon 10X S Fluor", "Magnification", "10");
   core.definePropertyBlock("Zeiss 4X Plan Apo", "Magnification", "4");

   // load devices
   // ------------
   cout << "Loading devices..." << endl;
   core.loadDevice("Camera", "DemoCamera", "DCam");
   core.loadDevice("Emission", "DemoCamera", "DWheel");
   core.loadDevice("Excitation", "DemoCamera", "DWheel");
   core.loadDevice("Dichroic", "DemoCamera", "DWheel");
   core.loadDevice("Objective", "DemoCamera", "DObjective");
   core.loadDevice("X", "DemoCamera", "DStage");
   core.loadDevice("Y", "DemoCamera", "DStage");
   core.loadDevice("Z", "DemoCamera", "DStage");

   core.initializeAllDevices();

   // set labels for state devices
   // emission filter
   core.defineStateLabel("Emission", 0, "Chroma-D460");
   core.defineStateLabel("Emission", 1, "Chroma-HQ620");
   core.defineStateLabel("Emission", 2, "Chroma-HQ535");
   core.defineStateLabel("Emission", 3, "Chroma-HQ700");

   // excitation filter
   core.defineStateLabel("Excitation", 2, "Chroma-D360");
   core.defineStateLabel("Excitation", 3, "Chroma-HQ480");
   core.defineStateLabel("Excitation", 4, "Chroma-HQ570");
   core.defineStateLabel("Excitation", 5, "Chroma-HQ620");

   // excitation dichroic
   core.defineStateLabel("Dichroic", 0, "400DCLP");
   core.defineStateLabel("Dichroic", 1, "Q505LP");
   core.defineStateLabel("Dichroic", 2, "Q585LP");

   // objective
   core.defineStateLabel("Objective", 1, "Nikon 10X S Fluor");
   core.defineStateLabel("Objective", 3, "Nikon 20X Plan Fluor ELWD");
   core.defineStateLabel("Objective", 5, "Zeiss 4X Plan Apo");

   // define settings
   core.defineConfig("Channel", "FITC", "Emission", "State", "2");
   core.defineConfig("Channel", "FITC", "Excitation", "State", "3");
   core.defineConfig("Channel", "FITC", "Dichroic", "State", "1");

   core.defineConfig("Channel", "DAPI", "Emission", "State", "1");
   core.defineConfig("Channel", "DAPI", "Excitation", "State", "2");
   core.defineConfig("Channel", "DAPI", "Dichroic", "State", "0");

   core.defineConfig("Channel", "Rhodamine", "Emission", "State", "3");
   core.defineConfig("Channel", "Rhodamine", "Excitation", "State", "4");
   core.defineConfig("Channel", "Rhodamine", "Dichroic", "State", "2");

   // set initial imaging mode
   core.setProperty("Camera", "Exposure", "55");
   core.setProperty("Objective", "Label", "Nikon 10X S Fluor");
   core.setConfig("Channel", "DAPI");
}
Example #12
0
TEST(CoreSanityTests, CreateAndReset)
{
   CMMCore c;
   c.reset();
}
Example #13
0
/**
* Creates MMCore object, loads configuration, prints the status and performs
* a couple of basic tests.
* 
* Modify to exercise specific devices in more detail.
*/
int _tmain(int argc, _TCHAR* argv[])
{
   int retval = 0;

   if (argc != 2)
   {
      cout << "Invalid number of command-line parameters." << endl;
      cout << "Use: Test_MMCore <configuration file name>" << endl;
      return 1;
   }

   try {
      // Create CMMCore      object
      CMMCore core;

      /*



      to test your device adapter you'll need to simply replace the 'demo' (simulation) equipment with your own
      For example:
      Assume you're writing a camera device adapter called   mmgr_dal_VendorCamera.dll
      Open the provided .cfg file with a text editor, then find the entry:

      #Devices
 ...
      Device,TheCamera,DemoCamera,DCam

      change that line to:

      Device,TheCamera,VendorCamera,DCam

       that's it!! 

      
      */



      // load system configuration
      core.loadSystemConfiguration(argv[1]);
      core.enableStderrLog(false); // supress console echo of log/debug messages
      std::cerr.flush();

      // print current device status
      // (this should work for any configuration)
      vector<string> devices = core.getLoadedDevices();
      for (size_t i=0; i<devices.size(); i++)
      {
         cout << devices[i] << endl;
         vector<string> props = core.getDevicePropertyNames(devices[i].c_str());
         for (size_t j=0; j<props.size(); j++)
         {
            string val = core.getProperty(devices[i].c_str(), props[j].c_str());
            cout << "    " << props[j] << "=" << val;
            if (core.hasPropertyLimits(devices[i].c_str(), props[j].c_str()))
            {
               cout << ", range: " << core.getPropertyLowerLimit(devices[i].c_str(), props[j].c_str())
                  << "-" << core.getPropertyUpperLimit(devices[i].c_str(), props[j].c_str());
            }
            cout << endl;
            std::cout.flush();
         }
      }

      cout << "Pixel size: " << core.getPixelSizeUm() << " um" << endl;

      // add any testing routines here...

      // TestDemoDevices is just an example for a testing rountine
      // It assumes that specific demo configuration is already loaded
      TestDemoDevices(core);
      TestAF(core);
      // TestColorMode(core);
      TestCameraLive(core);
      TestPixelSize(core);
      //TestHam(core);

      // clean-up before exiting


      /* in a more elaborate test you might want to insert the following:

      std::cout.flush();
      std::cerr.flush();
      core.enableStderrLog(true); // re-enable console echo of log/debug messages
      core.logMessage("IMLogger to cerr is re-enabled.");


      */

      core.unloadAllDevices();
   }
   catch (CMMError& err)
   {
      cout << "Exception: " << err.getMsg() << endl;
      cout << "Exiting now." << endl;
      retval = 1;
   }

   cout << (0==retval?"Test_MMCore ended OK.":"See errors above") << "\nPress Enter to terminate this program." << endl;
   std::cout.flush();
   std::cerr.flush();
   getchar();
   return retval;
}
Example #14
0
/**
* Test routine for the autofocus.
*/
void TestAF(CMMCore& core)
{
   std::cout << "Testing selected Autofocus device " << core.getAutoFocusDevice() << std::endl;
   core.fullFocus();
}
void TestHam(CMMCore& core)
{
   core.snapImage();
   core.getImage();
   core.setCameraDevice("CAM1");
   core.snapImage();
   core.getImage();
   cout << "CAM1 " << core.getImageWidth() << " X " << core.getImageHeight() << endl;
   core.setCameraDevice("CAM2");
   core.snapImage();
   core.getImage();
   cout << "CAM2 " << core.getImageWidth() << " X " << core.getImageHeight() << endl;
}
void TestHam(CMMCore& core)
{
   const char* camera = "CAM";

   unsigned height = core.getImageHeight();
   unsigned width = core.getImageWidth();

   //cout << "Setting bin size 4..." << endl;
   //core.setProperty(camera, "Binning", "4");
   //height = core.getImageHeight();
   //width = core.getImageWidth();
   //core.snapImage();
   //core.getImage();

   //cout << "Setting bin size 2..." << endl;
   //core.setProperty(camera, "Binning", "2");
   //height = core.getImageHeight();
   //width = core.getImageWidth();
   //core.snapImage();
   //core.getImage();

   core.setProperty(camera, "ScanMode", "1");
   cout << "Readout time (s): " << core.getProperty(camera, "ReadoutTime") << endl;

   cout << "Setting bin size 1..." << endl;
   core.setProperty(camera, "Binning", "1");
   core.setAutoShutter(false);
   height = core.getImageHeight();
   width = core.getImageWidth();
   core.setExposure(1000);

   unsigned char* pBuf = new unsigned char[core.getImageBufferSize()];
   //long startT = GetTickCount();
   core.snapImage();
   //long endT = GetTickCount() - startT;
   //cout << "snapImage() took " << endT << " ms" << endl;
   //startT = GetTickCount();
   void* pCamBuf = core.getImage();
   //endT = GetTickCount() - startT;
   memcpy(pBuf, pCamBuf, core.getImageBufferSize());
   //cout << "getImage() took " << endT << " ms" << endl;
   delete[] pBuf;

  // cout << "Setting ROI..." << endl;
  //// core.setROI(101, 267, 333, 674);
  // core.setROI(100, 100, 100, 100);
  // unsigned x, y, xSize, ySize;
  // core.getROI(x, y, xSize, ySize);
  // cout << "ROI set to:" << x << ", " << y << ", " << xSize << ", " << ySize << endl;

   //cout << "Setting the scan mode..." << endl;
   //core.setProperty(camera, "ScanMode", "1");
   //cout << "Scan mode: " << core.getProperty(camera, "ScanMode") << endl;
   ////cout << "Offset: " << core.getProperty(camera, "Offset") << endl;
   //cout << "Readout time (s): " << core.getProperty(camera, "ReadoutTime") << endl;
   //core.setProperty(camera, "ScanMode", "2");
   //cout << "Scan mode: " << core.getProperty(camera, "ScanMode") << endl;
   //cout << "Readout time (s): " << core.getProperty(camera, "ReadoutTime") << endl;

}
/**
 * Creates MMCore object, loads configuration, prints the status and performs
 * a couple of basic tests.
 * 
 * Modify to exercise specific devices in more detail.
 */
int main(int argc, char* argv[])
{
   if (argc != 2)
   {
      cout << "Invalid number of command-line parameters." << endl;
      cout << "Usage: Test_MMCore <configuration file name>" << endl;
      return 1;
   }

   try {
      // Create CMMCore      object
      CMMCore core;

      // load system configuration
	   core.loadSystemConfiguration(argv[1]);
      core.enableStderrLog(false); // supress console echo of log/debug messages
   
      // print current device status
      // (this should work for any configuration)
      vector<string> devices = core.getLoadedDevices();
      for (size_t i=0; i<devices.size(); i++)
      {
         cout << devices[i] << endl;
         vector<string> props = core.getDevicePropertyNames(devices[i].c_str());
         for (size_t j=0; j<props.size(); j++)
         {
            string val = core.getProperty(devices[i].c_str(), props[j].c_str());
            cout << "    " << props[j] << "=" << val;
            if (core.hasPropertyLimits(devices[i].c_str(), props[j].c_str()))
            {
               cout << ", range: " << core.getPropertyLowerLimit(devices[i].c_str(), props[j].c_str())
                    << "-" << core.getPropertyUpperLimit(devices[i].c_str(), props[j].c_str());
            }
            cout << endl;
        }
      }

      cout << "Pixel size: " << core.getPixelSizeUm() << " um" << endl;
	
      // add any testing routines here...

      // TestDemoDevices is just an example for a testing rountine
      // It assumes that specific demo configuration is already loaded
      //TestDemoDevices(core);
      //TestCameraStreaming(core);
      TestColorMode(core);
      //TestPixelSize(core);
      //TestHam(core);

      // clean-up before exiting
	   core.unloadAllDevices();
   }
   catch (CMMError& err)
   {
      cout << "Exception: " << err.getMsg() << endl;
      cout << "Exiting now." << endl;
      return 1;
   }

   cout << "Test_MMCore ended OK." << endl;
   return 0;
}
Example #18
0
/**
* Test routine for the 
*/
void TestCameraStreaming(CMMCore& core)
{
   const long numFrames = 20;
   const int memoryFootprintMB = 100;
   const double intervalMs = 300.0; // ms

   core.setCircularBufferMemoryFootprint(memoryFootprintMB);

   cout << "Buffer capacity: " << core.getBufferTotalCapacity() << endl;
   string camera = core.getCameraDevice();
   core.setExposure(200.0);

   // test normal mode
   core.snapImage();
   core.getImage();

   core.startSequenceAcquisition(numFrames, intervalMs, true);

   CDeviceUtils::SleepMs(5000);

   core.stopSequenceAcquisition();

   int count=0;
   while (core.deviceBusy(camera.c_str()))
   {
      Metadata md;
      core.getLastImageMD(0, 0, md);
      double interval = core.getBufferIntervalMs();
      printf("Displaying current image, %ld in que, %.0f ms interval.\n", core.getRemainingImageCount(), interval);
      MetadataSingleTag mdst = md.GetSingleTag(MM::g_Keyword_Elapsed_Time_ms);
      printf("Elapsed time %s, device %s\n", mdst.GetValue().c_str(), mdst.GetDevice().c_str());
   }
   printf("Camera finished with %.0f ms interval.\n", core.getBufferIntervalMs());
   core.setProperty(camera.c_str(), "ShutterMode", "Auto");



   cout << "Done! Free space =" << core.getBufferFreeCapacity() << endl;

   core.startSequenceAcquisition(numFrames, intervalMs, true);


   count=0;
   while (core.deviceBusy(camera.c_str()))
   {
      Metadata md;
      core.getLastImageMD(0, 0, md);
      double interval = core.getBufferIntervalMs();
      printf("Displaying current image, %ld in que, %.0f ms interval.\n", core.getRemainingImageCount(), interval);
      MetadataSingleTag mdst = md.GetSingleTag(MM::g_Keyword_Elapsed_Time_ms);
      printf("Elapsed time %s, device %s\n", mdst.GetValue().c_str(), mdst.GetDevice().c_str());
   }
   printf("Camera finished with %.0f ms interval.\n", core.getBufferIntervalMs());
   core.setProperty(camera.c_str(), "ShutterMode", "Auto");

}