示例#1
0
/**
* CAndorSDK3Camera constructor.
* Setup default all variables and create device properties required to exist
* before intialization. In this case, no such properties were required. All
* properties will be created in the Initialize() method.
*
* As a general guideline Micro-Manager devices do not access hardware in the
* the constructor. We should do as little as possible in the constructor and
* perform most of the initialization in the Initialize() method.
*/
CAndorSDK3Camera::CAndorSDK3Camera()
: CCameraBase<CAndorSDK3Camera> (),
  deviceManager(NULL),
  cameraDevice(NULL),
  bufferControl(NULL),
  startAcquisitionCommand(NULL),
  sendSoftwareTrigger(NULL),
  initialized_(false),
  b_cameraPresent_(false),
  number_of_devices_(0),
  deviceInUseIndex_(0),
  sequenceStartTime_(0),
  fpgaTSclockFrequency_(0),
  timeStamp_(0),
  defaultExposureTime_(0.0f),
  pDemoResourceLock_(0),
  image_buffers_(NULL),
  numImgBuffersAllocated_(0),
  currentSeqExposure_(0),
  keep_trying_(false),
  stopOnOverflow_(false)
{
   // call the base class method to set-up default error codes/messages
   InitializeDefaultErrorMessages();
   //Add in some others not currently in base impl, will show in CoreLog/Msgbox on error
   SetErrorText(DEVICE_BUFFER_OVERFLOW, " Circular Buffer Overflow code from MMCore");
   SetErrorText(DEVICE_OUT_OF_MEMORY, " Allocation Failure - out of memory");
   SetErrorText(DEVICE_SNAP_IMAGE_FAILED, " Snap Image Failure");
   
#ifdef TESTRESOURCELOCKING
   pDemoResourceLock_ = new MMThreadLock();
#endif
   thd_ = new MySequenceThread(this);

   // Create an atcore++ device manager
   deviceManager = new TDeviceManager;

   // Open a system device
   IDevice * systemDevice = deviceManager->OpenSystemDevice();
   IInteger * deviceCount = systemDevice->GetInteger(L"DeviceCount");
   SetNumberOfDevicesPresent(static_cast<int>(deviceCount->Get()));
   systemDevice->Release(deviceCount);
   IString * swVersion = systemDevice->GetString(L"SoftwareVersion");
   currentSoftwareVersion_ = swVersion->Get();
   systemDevice->Release(swVersion);
   deviceManager->CloseDevice(systemDevice);
}
int main(int argc, const char * argv[])
//int _tmain(int argc, _TCHAR* argv[])
{
    //InitSpokesRuntime();

	// create session manager
	ISessionManager *sessionManager = nullptr;
	if( SM_RESULT_SUCCESS == getSessionManager(&sessionManager) )
	{
		// create session
		ISession* session = nullptr;
		if( SM_RESULT_SUCCESS == sessionManager->registerSession( L"Spokes Wearing Sensor Native Sample", &session ) )
		{
			IDevice* activeDevice = nullptr;
			if( SM_RESULT_SUCCESS != session->getActiveDevice( &activeDevice ) )
			{
				wcout << "there is no active devices, please attach one then run the app again" << endl;
				activeDevice = nullptr;
			}
			else
			{
				// Get device listener
				pDeviceListener dev_listener = nullptr;
				auto dm_result = activeDevice->getDeviceListener(&dev_listener);

				if(dm_result != DM_RESULT_SUCCESS) 
				{
					wcout << "failed to get device listener interface" << endl;
				}
				else
				{
					// Register device listener callbacks
					IDeviceListenerCallback* deviceListenerEventSink( new DeviceListenerEventSink() );
					dm_result = dev_listener->registerCallback(deviceListenerEventSink);

					if(dm_result != DM_RESULT_SUCCESS)
					{
						wcout << "failed to register device listener callback" << endl;
					}
				}
			}

			wcout << "Press enter to quit..." << endl;
			cin.ignore();

			if (activeDevice != nullptr) activeDevice->Release();
			sessionManager->unregisterSession( session );
			session->Release();
			sessionManager->Release();
		    //ShutDownSpokesRuntime();
		}
	}
	return 0;
}