Esempio n. 1
0
int ImagingBindingService::GetStatus(_timg__GetStatus *timg__GetStatus, _timg__GetStatusResponse *timg__GetStatusResponse) 
{
	std::cout << __FUNCTION__ << std::endl;
	ServiceContext* ctx = (ServiceContext*)this->soap->user;
	
	auto it = ctx->m_devices.find(timg__GetStatus->VideoSourceToken);
	if (it != ctx->m_devices.end())
	{	
		timg__GetStatusResponse->Status = soap_new_tt__ImagingStatus20(this->soap);
		timg__GetStatusResponse->Status->FocusStatus20 = soap_new_tt__FocusStatus20(this->soap);
		
		timg__GetStatusResponse->Status->FocusStatus20->Position = ctx->getCtrlValue(it->first, V4L2_CID_FOCUS_ABSOLUTE);
		int status = ctx->getCtrlValue(it->first,V4L2_CID_AUTO_FOCUS_STATUS);
		tt__MoveStatus moveStatus = tt__MoveStatus__UNKNOWN;
		switch (status)
		{
			case V4L2_AUTO_FOCUS_STATUS_IDLE: moveStatus = tt__MoveStatus__IDLE  ; break;
			case V4L2_AUTO_FOCUS_STATUS_BUSY: moveStatus = tt__MoveStatus__MOVING; break;
		}
		timg__GetStatusResponse->Status->FocusStatus20->MoveStatus = moveStatus;
	}
	
	return SOAP_OK;
}
Esempio n. 2
0
int ImagingBindingService::GetImagingSettings(_timg__GetImagingSettings *timg__GetImagingSettings, _timg__GetImagingSettingsResponse *timg__GetImagingSettingsResponse)  
{
	std::cout << __FUNCTION__ << std::endl;
	ServiceContext* ctx = (ServiceContext*)this->soap->user;
	
	auto it = ctx->m_devices.find(timg__GetImagingSettings->VideoSourceToken);
	if (it != ctx->m_devices.end())
	{
		timg__GetImagingSettingsResponse->ImagingSettings = soap_new_tt__ImagingSettings20(this->soap);

		float brightness = ctx->getCtrlValue(it->first, V4L2_CID_BRIGHTNESS);
		if ( errno == 0 )
		{
			timg__GetImagingSettingsResponse->ImagingSettings->Brightness = soap_new_ptr(this->soap, brightness);
		}
	
		float contrast = ctx->getCtrlValue(it->first, V4L2_CID_CONTRAST);
		if ( errno == 0 )
		{
			timg__GetImagingSettingsResponse->ImagingSettings->Contrast = soap_new_ptr(this->soap, contrast);
		}

		float saturation = ctx->getCtrlValue(it->first, V4L2_CID_SATURATION);
		if ( errno == 0 )
		{
			timg__GetImagingSettingsResponse->ImagingSettings->ColorSaturation = soap_new_ptr(this->soap, saturation);
		}

		float sharpness = ctx->getCtrlValue(it->first, V4L2_CID_SHARPNESS);
		if ( errno == 0 )
		{
			timg__GetImagingSettingsResponse->ImagingSettings->Sharpness = soap_new_ptr(this->soap, sharpness);
		}

		int backlightCompensation = ctx->getCtrlValue(it->first, V4L2_CID_BACKLIGHT_COMPENSATION);
		if ( errno == 0 )
		{
			timg__GetImagingSettingsResponse->ImagingSettings->BacklightCompensation = soap_new_tt__BacklightCompensation20(this->soap);
			timg__GetImagingSettingsResponse->ImagingSettings->BacklightCompensation->Mode = backlightCompensation ? tt__BacklightCompensationMode__ON : tt__BacklightCompensationMode__OFF;
		}

		int wideDynamicRange = ctx->getCtrlValue(it->first, V4L2_CID_WIDE_DYNAMIC_RANGE);
		if ( errno == 0 )
		{
			timg__GetImagingSettingsResponse->ImagingSettings->WideDynamicRange = soap_new_tt__WideDynamicRange20(this->soap);
			timg__GetImagingSettingsResponse->ImagingSettings->WideDynamicRange->Mode = wideDynamicRange ? tt__WideDynamicMode__ON : tt__WideDynamicMode__OFF;
		}
		
		int exposure = ctx->getCtrlValue(it->first, V4L2_CID_EXPOSURE_AUTO);		
		if ( errno == 0 )
		{
			timg__GetImagingSettingsResponse->ImagingSettings->Exposure = soap_new_tt__Exposure20(this->soap);
			timg__GetImagingSettingsResponse->ImagingSettings->Exposure->Mode = exposure ? tt__ExposureMode__AUTO : tt__ExposureMode__MANUAL;
			float exposureTime = ctx->getCtrlValue(it->first, V4L2_CID_EXPOSURE_ABSOLUTE);
			timg__GetImagingSettingsResponse->ImagingSettings->Exposure->ExposureTime = soap_new_ptr(this->soap, exposureTime);
		}
				
		int autoWhiteBalance = ctx->getCtrlValue(it->first, V4L2_CID_AUTO_WHITE_BALANCE);		
		if ( errno == 0 )
		{
			timg__GetImagingSettingsResponse->ImagingSettings->WhiteBalance = soap_new_tt__WhiteBalance20(this->soap);
			timg__GetImagingSettingsResponse->ImagingSettings->WhiteBalance->Mode = autoWhiteBalance ? tt__WhiteBalanceMode__AUTO : tt__WhiteBalanceMode__MANUAL;
			float redBalance = ctx->getCtrlValue(it->first, V4L2_CID_RED_BALANCE);		
			timg__GetImagingSettingsResponse->ImagingSettings->WhiteBalance->CrGain = soap_new_ptr(this->soap, redBalance);
			float blueBalance = ctx->getCtrlValue(it->first, V4L2_CID_BLUE_BALANCE);		
			timg__GetImagingSettingsResponse->ImagingSettings->WhiteBalance->CrGain = soap_new_ptr(this->soap, blueBalance);
		}

		int autofocusMode = ctx->getCtrlValue(it->first, V4L2_CID_FOCUS_AUTO);
		if ( errno == 0 )
		{
			timg__GetImagingSettingsResponse->ImagingSettings->Focus = soap_new_tt__FocusConfiguration20(this->soap);
			timg__GetImagingSettingsResponse->ImagingSettings->Focus->AutoFocusMode = autofocusMode ? tt__AutoFocusMode__AUTO : tt__AutoFocusMode__MANUAL;
		}
		 
	}
	
	return SOAP_OK;
}