/**
 * 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;
}
/**
 * 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;
}
/**
* 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;
}