Exemplo n.º 1
0
void CameraXIMEA::startCapture(){

    if(triggerMode == triggerModeHardware){
        xiSetParamInt(camera, XI_PRM_ACQ_TIMING_MODE, XI_ACQ_TIMING_MODE_FREE_RUN);

        // Configure for hardware trigger
        stat = xiSetParamInt(camera, XI_PRM_TRG_SOURCE, XI_TRG_EDGE_RISING);
        HandleResult(stat,"xiSetParam (XI_PRM_TRG_SOURCE)");

        // Configure for exposure active trigger
        stat = xiSetParamInt(camera, XI_PRM_TRG_SELECTOR, XI_TRG_SEL_FRAME_START);
        HandleResult(stat,"xiSetParam (XI_PRM_TRG_SELECTOR)");

    } else if(triggerMode == triggerModeSoftware){
        // Configure for software trigger (for getSingleFrame())
        stat = xiSetParamInt(camera, XI_PRM_TRG_SOURCE, XI_TRG_SOFTWARE);
        HandleResult(stat,"xiSetParam (XI_PRM_TRG_SOURCE)");
    }

    // Start aquistion
    stat = xiStartAcquisition(camera);
    HandleResult(stat,"xiStartAcquisition");

    capturing = true;

}
Exemplo n.º 2
0
int _tmain(int argc, _TCHAR* argv[])
{
	// image buffer
	XI_IMG image;
	memset(&image,0,sizeof(image));
	image.size = sizeof(XI_IMG);

	// Sample for XIMEA API V4.05
	HANDLE xiH = NULL;
	XI_RETURN stat = XI_OK;
	
	// Retrieving a handle to the camera device 
	printf("Opening first camera...\n");
	stat = xiOpenDevice(0, &xiH);
	HandleResult(stat,"xiOpenDevice");
	
	// Setting "exposure" parameter (10ms=10000us)
	stat = xiSetParamInt(xiH, XI_PRM_EXPOSURE, 10000);
	HandleResult(stat,"xiSetParam (exposure set)");
	
	// Note:
	// The default parameters of each camera might be different in different API versions
	// In order to ensure that your application will have camera in expected state,
	// please set all parameters expected by your application to required value.
	
	printf("Starting acquisition...\n");
	stat = xiStartAcquisition(xiH);
	HandleResult(stat,"xiStartAcquisition");
	
	#define EXPECTED_IMAGES 10
	for (int images=0;images < EXPECTED_IMAGES;images++)
	{
		// getting image from camera
		stat = xiGetImage(xiH, 5000, &image);
		HandleResult(stat,"xiGetImage");
		unsigned char pixel = *(unsigned char*)image.bp;
		printf("Image %d (%dx%d) received from camera. First pixel value: %d\n", images, (int)image.width, (int)image.height, pixel);
	}
	
	printf("Stopping acquisition...\n");
	xiStopAcquisition(xiH);
	xiCloseDevice(xiH);
finish:
	printf("Done\n");
#ifdef WIN32
	Sleep(2000);
#endif
	return 0;
}
bool RequestAlbumEditTask::HandleCallback(const string& url, bool requestRet, const char* buf, int size){
	FileLog("httprequest", "RequestAlbumEditTask::HandleCallback( "
			"url : %s,"
			"requestRet : %s "
			")",
			url.c_str(),
			requestRet?"true":"false"
			);

	if (size < MAX_LOG_BUFFER) {
		FileLog("httprequest", "RequestAlbumEditTask::HandleCallback( buf( %d ) : %s )", size, buf);
	}

	string errnum = "";
	string errmsg = "";
	bool bFlag = false;
	bool bContinue = true;

	if (requestRet) {
		// request success
		Json::Value dataJson;
		bFlag = HandleResult(buf, size, errnum, errmsg, &dataJson, NULL, &bContinue);
	} else {
		// request fail
		errnum = LOCAL_ERROR_CODE_TIMEOUT;
		errmsg = LOCAL_ERROR_CODE_TIMEOUT_DESC;
	}

	if( bContinue && mpCallback != NULL ) {
		mpCallback->OnAlbumEdit(bFlag, errnum, errmsg, this);
	}

	return bFlag;
}
Exemplo n.º 4
0
bool CRunSession::OnProcessMessage (const SArchonMessage &Msg)

//	OnProcessMessage
//
//	Handle a message

	{
	//	If we a reply, then process it

	if (m_iState == stateWaitingForHexarcReply)
		{
		//	continue with execution

		CDatum dResult;
		CHexeProcess::ERunCodes iRun = m_Process.RunContinues(CSimpleEngine::MessageToHexeResult(Msg), &dResult);

		//	Handle it

		return HandleResult(iRun, dResult);
		}

	//	Otherwise we are done.

	return false;
	}
Exemplo n.º 5
0
NS_IMETHODIMP
FileSystemTaskParentBase::Run()
{
  // This method can run in 2 different threads. Here why:
  // 1. We are are on the I/O thread and we call IOWork().
  // 2. After step 1, it returns back to the PBackground thread.

  // Run I/O thread tasks
  if (!IsOnBackgroundThread()) {
    nsresult rv = IOWork();
    if (NS_WARN_IF(NS_FAILED(rv))) {
      SetError(rv);
    }

    // Let's go back to PBackground thread to finish the work.
    rv = mBackgroundEventTarget->Dispatch(this, NS_DISPATCH_NORMAL);
    if (NS_WARN_IF(NS_FAILED(rv))) {
      return rv;
    }

    return NS_OK;
  }

  // If we are here, it's because the I/O work has been done and we have to
  // handle the result back via IPC.
  AssertIsOnBackgroundThread();
  HandleResult();
  return NS_OK;
}
/* IHttpRequestManagerCallback */
void RequestFakeController::onSuccess(long requestId, string url, const char* buf, int size) {
	FileLog("httprequest",
			"RequestFakeController::onSuccess( url : %s, content-type : %s, buf( size : %d ) )",
			url.c_str(),
			GetContentTypeById(requestId).c_str(),
			size
			);

	if (size < MAX_LOG_BUFFER) {
		FileLog("httprequest", "RequestFakeController::onSuccess(), buf: %s", buf);
	}

	/* parse base result */
	string errnum = "";
	string errmsg = "";
	Json::Value data;
	Json::Value errdata;

	bool bFlag = HandleResult(buf, size, errnum, errmsg, &data, &errdata);

	/* resopned parse ok, callback success */
	if( url.compare(FAKE_CHECK_SERVER_PATH) == 0 ) {
		/* 2.1.检查真假服务器 */
		CheckServerItem item;
		item.Parse(data);

		if( mpRequestFakeControllerCallback != NULL ) {
			mpRequestFakeControllerCallback->OnCheckServer(requestId, bFlag, item, errnum, errmsg);
		}
	}

	FileLog("httprequest", "RequestFakeController::onSuccess() end, url:%s", url.c_str());
}
Exemplo n.º 7
0
bool RequestUploadTask::HandleCallback(const string& url, bool requestRet, const char* buf, int size) {
	FileLog(
			SnifferLogFileName,
			"RequestUploadTask::HandleResult( "
			"url : %s,"
			"requestRet : %s "
			")",
			url.c_str(),
			requestRet?"true":"false"
			);

	if (size < MAX_LOG_BUFFER) {
		FileLog(SnifferLogFileName, "RequestUploadTask::HandleResult( buf( %d ) : %s )", size, buf);
	}

	bool bFlag = false;
	string filePath = "";

	if (requestRet) {
		// request success
		Json::Value dataJson;
		if( HandleResult(buf, size, &dataJson) ) {
			bFlag = true;
			filePath = dataJson["filePath"].asString();
		}
	}

	if( mpCallback != NULL ) {
		mpCallback->OnUpload(bFlag, filePath, this);
	}

	return bFlag;
}
Exemplo n.º 8
0
/*
 * Run print most significant realtors report command
*/
static bool RunPrintRealventRealtorReport(char** params, Yad3Program program) {
	if ((params[2] != NULL)) {
		Yad3ServiceResult result = yad3ServicePrintClientsRealventAgents(
			program->service, params[2], program->output);
		return HandleResult(result);
	}
	writeToErrorOutStream(MTM_INVALID_COMMAND_LINE_PARAMETERS);
	return false;
}
Exemplo n.º 9
0
/*
 * Run print most paying costumers report command
*/
static bool RunPayingCustumersReport(char** params, Yad3Program program) {
	if ((params[2] != NULL)) {
		Yad3ServiceResult result = yad3ServicePrintMostPayingClients(
			program->service, stringToInt(params[2]), program->output);
		return HandleResult(result);
	}
	writeToErrorOutStream(MTM_INVALID_COMMAND_LINE_PARAMETERS);
	return false;
}
Exemplo n.º 10
0
/*
 * Run RemoveCustumer command
*/
static bool RunRemoveCustumer(char** params, Yad3Program program) {
	if (params[2] != NULL) {
		Yad3ServiceResult result = yad3ServiceRemoveClient(program->service,
			params[2]);
		return HandleResult(result);
	}
	writeToErrorOutStream(MTM_INVALID_COMMAND_LINE_PARAMETERS);
	return false;
}
Exemplo n.º 11
0
/*
 * Run RemoveApartmentFromRealtor command
 */
static bool RunResponeToOffer(char** params, Yad3Program program) {
	if ((params[2] != NULL) && (params[3] != NULL) && (params[4] != NULL)) {
			Yad3ServiceResult result = yad3ServiceRespondToClientOffer(
				program->service, params[2], params[3], params[4]);
			return HandleResult(result);
		}
		writeToErrorOutStream(MTM_INVALID_COMMAND_LINE_PARAMETERS);
		return false;
}
Exemplo n.º 12
0
/*
 * Run RealtorAddApartmentService command
 */
static bool RunRealtorAddApartmentService(char** params, Yad3Program program) {
	if ((params[2] != NULL) && (params[3] != NULL) && (params[4] != NULL)) {
			Yad3ServiceResult result = yad3ServiceAddServiceToAgent(program->
				service, params[2], params[3], stringToInt(params[4]));
			return HandleResult(result);
		}
		writeToErrorOutStream(MTM_INVALID_COMMAND_LINE_PARAMETERS);
		return false;
}
Exemplo n.º 13
0
NS_IMETHODIMP
FileSystemTaskParentBase::Run()
{
  // This method can run in 3 different threads. Here why:
  // 1. if we are on the main-thread it's because the task must do something
  //    here. If no errors are returned we go the step 2.
  // 2. We can be here directly if the task doesn't have nothing to do on the
  //    main-thread. We are are on the I/O thread and we call IOWork().
  // 3. Both step 1 (in case of error) and step 2 end up here where return the
  //    value back to the PBackground thread.
  if (NS_IsMainThread()) {
    MOZ_ASSERT(NeedToGoToMainThread());

    nsresult rv = MainThreadWork();
    if (NS_WARN_IF(NS_FAILED(rv))) {
      SetError(rv);

      // Something when wrong. Let's go to the Background thread directly
      // skipping the I/O thread step.
      rv = mBackgroundEventTarget->Dispatch(this, NS_DISPATCH_NORMAL);
      if (NS_WARN_IF(NS_FAILED(rv))) {
        return rv;
      }
    }

    // Next step must happen on the I/O thread.
    rv = DispatchToIOThread(this);
    if (NS_WARN_IF(NS_FAILED(rv))) {
      return rv;
    }

    return NS_OK;
  }

  // Run I/O thread tasks
  if (!IsOnBackgroundThread()) {
    nsresult rv = IOWork();
    if (NS_WARN_IF(NS_FAILED(rv))) {
      SetError(rv);
    }

    // Let's go back to PBackground thread to finish the work.
    rv = mBackgroundEventTarget->Dispatch(this, NS_DISPATCH_NORMAL);
    if (NS_WARN_IF(NS_FAILED(rv))) {
      return rv;
    }

    return NS_OK;
  }

  // If we are here, it's because the I/O work has been done and we have to
  // handle the result back via IPC.
  AssertIsOnBackgroundThread();
  HandleResult();
  return NS_OK;
}
Exemplo n.º 14
0
CameraFrame CameraXIMEA::getFrame(){

    // Create single image buffer
    XI_IMG image;
    image.size = sizeof(XI_IMG); // must be initialized
    //image.bp = NULL;
    //image.bp_size = 0;

    if(triggerMode == triggerModeSoftware){
        // Fire software trigger
        stat = xiSetParamInt(camera, XI_PRM_TRG_SOFTWARE, 0);
        HandleResult(stat,"xiSetParam (XI_PRM_TRG_SOFTWARE)");

        // Retrieve image from camera
        stat = xiGetImage(camera, 1000, &image);
        HandleResult(stat,"xiGetImage");
    } else {

        // Retrieve image from camera
        stat = xiGetImage(camera, 1000, &image);
        HandleResult(stat,"xiGetImage");
    }

//    // Empty buffer
//    while(xiGetImage(camera, 1, &image) == XI_OK){
//        std::cerr << "drop!" << std::endl;
//        continue;
//    }

    //std::cout << image.exposure_time_us  << std::endl << std::flush;
    //std::cout << image.exposure_sub_times_us[3]  << std::endl << std::flush;
    //std::cout << image.GPI_level  << std::endl << std::flush;

    CameraFrame frame;
    frame.height = image.height;
    frame.width = image.width;
    frame.memory = (unsigned char*)image.bp;
    frame.timeStamp = image.tsUSec;
    frame.sizeBytes = image.bp_size;
    frame.flags = image.GPI_level;

    return frame;
}
Exemplo n.º 15
0
/*
 * Run RunMakeOffer command
*/
static bool RunMakeOffer(char** params, Yad3Program program) {
	if ((params[2] != NULL) && (params[3] != NULL) && (params[4] != NULL)
			&& (params[5] != NULL) && (params[6] != NULL)) {
		Yad3ServiceResult result = yad3ServiceMakeClientOffer(program->service,
			params[2], params[3], params[4], stringToInt(params[5]),
			stringToInt(params[6]));
		return HandleResult(result);
	}
	writeToErrorOutStream(MTM_INVALID_COMMAND_LINE_PARAMETERS);
	return false;
}
Exemplo n.º 16
0
CameraXIMEA::~CameraXIMEA(){

    if(capturing){
        // Stop acquisition
        stat = xiStopAcquisition(camera);
        HandleResult(stat,"xiStopAcquisition");
    }

    // Close device
    xiCloseDevice(camera);
}
Exemplo n.º 17
0
__interrupt void isrAnalogToDigital(void)
{
	ADC12IV = 0;	// We should only ever get an expected interrupt

	if (HandleResult(currentRequest))
	{
		EXIT_LPM_ISR();
	}
	currentRequest++;
	if (currentRequest >= MAX_REQUESTS)
		currentRequest = 0;
	Launch(currentRequest);
}
void RequestAdvertController::AdmirerListAdCallbackHandle(long requestId, const string& url, bool requestRet, const char* buf, int size)
{
    string advertId = "";
    string errnum = "";
    string errmsg = "";
    string htmlCode = "";
    string advertTitle = "";
    bool bFlag = false;
    
    if (requestRet) {
        // request success
        Json::Value dataJson;
        if( HandleResult(buf, size, errnum, errmsg, &dataJson) ) {
            if (dataJson[ADVERT_ADVERTID].isString()) {
                advertId = dataJson[ADVERT_ADVERTID].asString();
               
            }
            if (dataJson[ADVERT_HTMLCODE].isString()) {
                htmlCode = dataJson[ADVERT_HTMLCODE].asString();
            }
            
            if (dataJson[ADVERT_ADVERTTITLE].isString()) {
                advertTitle = dataJson[ADVERT_ADVERTTITLE].asString();
            }
            
            
            if (errnum.length() <= 0) {
                bFlag = true;
            }
            if (!bFlag) {
                // parsing fail
                errnum = LOCAL_ERROR_CODE_PARSEFAIL;
                errmsg = LOCAL_ERROR_CODE_PARSEFAIL_DESC;
                
                FileLog("httprequest", "RequestAdvertController::AdmirerListAdCallbackHandle() parsing fail:"
                        "(url:%s, size:%d, buf:%s)",
                        url.c_str(), size, buf);
            }
        }
    }
    else {
        // request fail
        errnum = LOCAL_ERROR_CODE_TIMEOUT;
        errmsg = LOCAL_ERROR_CODE_TIMEOUT_DESC;
    }
    
    if( m_Callback.onRequestAdmirerListAd != NULL ) {
        m_Callback.onRequestAdmirerListAd(requestId, bFlag, errnum, errmsg, advertId, htmlCode, advertTitle);
    }
}
bool RequestAlbumListTask::HandleCallback(const string& url, bool requestRet, const char* buf, int size) {
    FileLog("httprequest", "RequestAlbumListTask::HandleCallback( "
            "url : %s,"
            "requestRet : %s "
            ")",
            url.c_str(),
            requestRet?"true":"false"
           );

    if (size < MAX_LOG_BUFFER) {
        FileLog("httprequest", "RequestAlbumListTask::HandleCallback( buf( %d ) : %s )", size, buf);
    }

    list<AlbumItem> itemList;
    string errnum = "";
    string errmsg = "";
    bool bFlag = false;
    bool bContinue = true;

    if (requestRet) {
        // request success
        Json::Value dataJson;
        if( HandleResult(buf, size, errnum, errmsg, &dataJson, NULL, &bContinue) ) {

            if( dataJson[COMMON_DATA_LIST].isArray() ) {
                for(int i = 0; i < dataJson[COMMON_DATA_LIST].size(); i++ ) {
                    AlbumItem item;
                    item.Parse(dataJson[COMMON_DATA_LIST].get(i, Json::Value::null));
                    itemList.push_back(item);
                }
                bFlag = true;
            } else {
                // parsing fail
                bFlag = false;
                errnum = LOCAL_ERROR_CODE_PARSEFAIL;
                errmsg = LOCAL_ERROR_CODE_PARSEFAIL_DESC;
            }
        }
    } else {
        // request fail
        errnum = LOCAL_ERROR_CODE_TIMEOUT;
        errmsg = LOCAL_ERROR_CODE_TIMEOUT_DESC;
    }

    if( bContinue && mpCallback != NULL ) {
        mpCallback->OnQueryAlbumList(bFlag, errnum, errmsg, itemList, this);
    }

    return bFlag;
}
bool RequestLCGetVideoTask::HandleCallback(const string& url, bool requestRet, const char* buf, int size)
{
	FileLog("httprequest", "RequestLCGetVideoTask::HandleResult( "
			"url : %s,"
			"requestRet : %s "
			")",
			url.c_str(),
			requestRet?"true":"false"
			);

	if (size < MAX_LOG_BUFFER) {
		FileLog("httprequest", "RequestLCGetVideoTask::HandleResult( buf( %d ) : %s )", size, buf);
	}

	string errnum = "";
	string errmsg = "";
	string videoUrl = "";
	bool bFlag = false;
	bool bContinue = true;
	if (requestRet) {
		// request success
		TiXmlDocument doc;
		if( HandleResult(buf, size, errnum, errmsg, doc, &bContinue) ) {
			bFlag = true;

			TiXmlNode *rootNode = doc.FirstChild(COMMON_ROOT);
			if (NULL != rootNode) {
				// group list
				TiXmlNode *videoNode = rootNode->FirstChild(LC_GETVIDEO_VIDEO_URL);
				if (NULL != videoNode) {
					TiXmlElement* videoUrlElement  = videoNode->ToElement();
					if (NULL != videoUrlElement) {
						videoUrl = videoUrlElement->GetText();
					}
				}

			}
		}
	} else {
		// request fail
		errnum = LOCAL_ERROR_CODE_TIMEOUT;
		errmsg = LOCAL_ERROR_CODE_TIMEOUT_DESC;
	}

	if( bContinue && mpCallback != NULL ) {
		mpCallback->OnGetVideo(bFlag, errnum, errmsg, videoUrl, this);
	}

	return bFlag;
}
Exemplo n.º 21
0
NS_IMETHODIMP
FileSystemTaskBase::Run()
{
  if (!NS_IsMainThread()) {
    // Run worker thread tasks
    Work();
    // Dispatch itself to main thread
    NS_DispatchToMainThread(this);
    return NS_OK;
  }

  // Run main thread tasks
  HandleResult();
  return NS_OK;
}
Exemplo n.º 22
0
void CaptureCAM_XIMEA::addTrigger(int timout, bool triggered)
{
    int mvret = XI_OK;
    mvret = xiStopAcquisition(hmv);
    HandleResult(mvret, "Acquisition stopped");
    isopened=false;
    if(triggered){
        // select trigger source
        mvret = xiSetParamInt(hmv, XI_PRM_TRG_SOURCE, XI_TRG_EDGE_RISING);
        HandleResult(mvret, "Error while activating external trigger source");
        // select input pin 1 mode
        mvret = xiSetParamInt(hmv, XI_PRM_GPI_SELECTOR, 1);
        HandleResult(mvret, "Error while setting input pin");
        mvret = xiSetParamInt(hmv, XI_PRM_GPI_MODE, XI_GPI_TRIGGER);
        HandleResult(mvret, "Error while setting input pin mode");
        // set digital output 1 mode
        mvret = xiSetParamInt(hmv, XI_PRM_GPO_SELECTOR, 1);
        HandleResult(mvret, "Error while setting digital ouput");
        mvret = xiSetParamInt(hmv, XI_PRM_GPO_MODE,  XI_GPO_EXPOSURE_ACTIVE);
        HandleResult(mvret, "Error while setting digital output mode");
        
        mvret = xiSetParamInt(hmv, XI_PRM_ACQ_TIMING_MODE, XI_ACQ_TIMING_MODE_FREE_RUN);
        HandleResult(mvret, "Error while setting timing mode.");

        trigger = true;
        printf("External trigger is on");
    }else{
        /* NOT WORKING IF XI_PRM_BUFFERS_QUEUE_SIZE is set to a value < 3*/
        mvret = xiSetParamInt(hmv, XI_PRM_BUFFERS_QUEUE_SIZE, 3);
        if( mvret != XI_OK)
            errMsg("Set parameter error (XI_PRM_BUFFERS_QUEUE_SIZE)", mvret);
        mvret = xiSetParamInt(hmv, XI_PRM_RECENT_FRAME, 1);
        if( mvret != XI_OK)
            errMsg("Set parameter error (XI_PRM_RECENT_FRAME)", mvret);
        mvret = xiSetParamInt(hmv, XI_PRM_TRG_SOURCE, XI_TRG_SOFTWARE);
        if( mvret != XI_OK){
            errMsg("Error while disabling external trigger source", mvret);
        }
        trigger = false;
        printf("External trigger is off");
    }
    mvret = xiStartAcquisition(hmv);
    if(mvret != XI_OK)
    {
        errMsg("StartAcquisition XI_DEVICE failed", mvret);
        close();
    }
    timeout = timout;
    isopened=true;
}
bool RequestAlbumCreateTask::HandleCallback(const string& url, bool requestRet, const char* buf, int size){
	FileLog("httprequest", "RequestAlbumCreateTask::HandleCallback( "
			"url : %s,"
			"requestRet : %s "
			")",
			url.c_str(),
			requestRet?"true":"false"
			);

	if (size < MAX_LOG_BUFFER) {
		FileLog("httprequest", "RequestAlbumCreateTask::HandleCallback( buf( %d ) : %s )", size, buf);
	}

	string albumId = "";
	string errnum = "";
	string errmsg = "";
	bool bFlag = false;
	bool bContinue = true;

	if (requestRet) {
		// request success
		Json::Value dataJson;
		if( HandleResult(buf, size, errnum, errmsg, &dataJson, NULL, &bContinue) ) {
			if(dataJson[ALBUM_ALBUM_ID].isString()){
				albumId = dataJson[ALBUM_ALBUM_ID].asString();
				bFlag = true;
			}else {
				// parsing fail
				bFlag = false;
				errnum = LOCAL_ERROR_CODE_PARSEFAIL;
				errmsg = LOCAL_ERROR_CODE_PARSEFAIL_DESC;
			}
		}
	} else {
		// request fail
		errnum = LOCAL_ERROR_CODE_TIMEOUT;
		errmsg = LOCAL_ERROR_CODE_TIMEOUT_DESC;
	}

	if( bContinue && mpCallback != NULL ) {
		mpCallback->OnAlbumCreate(bFlag, errnum, errmsg, albumId, this);
	}

	return bFlag;
}
Exemplo n.º 24
0
NS_IMETHODIMP
FileSystemTaskBase::Run()
{
  if (!NS_IsMainThread()) {
    // Run worker thread tasks
    nsresult rv = Work();
    if (NS_FAILED(rv)) {
      SetError(rv);
    }
    // Dispatch itself to main thread
    NS_DispatchToMainThread(this);
    return NS_OK;
  }

  // Run main thread tasks
  HandleResult();
  return NS_OK;
}
void RequestAdvertController::PushAdvertCallbackHandle(long requestId, const string& url, bool requestRet, const char* buf, int size)
{
	AdPushAdvertList list;
	string errnum = "";
	string errmsg = "";
	bool bFlag = false;

	if (requestRet) {
		// request success
		Json::Value dataJson;
		if( HandleResult(buf, size, errnum, errmsg, &dataJson) ) {
			if (dataJson[COMMON_DATA_LIST].isArray()) {
				bFlag = true;

				int i = 0;
				for (i = 0; i < dataJson[COMMON_DATA_LIST].size(); i++) {
					AdPushAdvertItem item;
					if (item.Parsing(dataJson[COMMON_DATA_LIST].get(i, Json::Value::null))) {
						list.push_back(item);
					}
				}
			}

			if (!bFlag) {
				// parsing fail
				errnum = LOCAL_ERROR_CODE_PARSEFAIL;
				errmsg = LOCAL_ERROR_CODE_PARSEFAIL_DESC;

				FileLog("httprequest", "RequestAdvertController::WomanListAdvertCallbackHandle() parsing fail:"
						"(url:%s, size:%d, buf:%s)",
						url.c_str(), size, buf);
			}
		}
	}
	else {
		// request fail
		errnum = LOCAL_ERROR_CODE_TIMEOUT;
		errmsg = LOCAL_ERROR_CODE_TIMEOUT_DESC;
	}

	if( m_Callback.onRequestAdPushAdvert != NULL ) {
		m_Callback.onRequestAdPushAdvert(requestId, bFlag, errnum, errmsg, list);
	}
}
Exemplo n.º 26
0
bool CRunSession::OnStartSession (const SArchonMessage &Msg, DWORD dwTicket)

//	OnStartSession
//
//	Start the session

	{
	CDatum dCode = Msg.dPayload.GetElement(0);

	//	Initialize the process

	m_Process.LoadLibrary(LIBRARY_CORE);

	//	Parse into an expression (depending on the type of input)

	CDatum dExpression;
	if (dCode.GetBasicType() == CDatum::typeString)
		{
		CString sError;
		if (!CHexeDocument::ParseLispExpression(dCode, &dExpression, &sError))
			{
			SendMessageReplyError(MSG_ERROR_UNABLE_TO_COMPLY, strPattern(ERR_COMPILER, sError));
			return false;
			}
		}

	//	Otherwise we don't know how to parse the input

	else
		{
		SendMessageReplyError(MSG_ERROR_UNABLE_TO_COMPLY, ERR_UNABLE_TO_PARSE_CODE);
		return false;
		}

	//	Run the code

	CDatum dResult;
	CHexeProcess::ERunCodes iRun = m_Process.Run(dExpression, &dResult);

	//	Deal with the result

	return HandleResult(iRun, dResult);
	}
Exemplo n.º 27
0
 void AccountLayout::optsRename_Click()
 {
     std::string name = AskForText(set::GetDictionaryEntry(213), "");
     if(name != "")
     {
         if(name.length() <= 10)
         {
             strcpy(this->pbase->username, name.c_str());
             Result rc = this->pred->Store(this->pbase, this->udata);
             if(rc == 0)
             {
                 mainapp->LoadMenuHead(set::GetDictionaryEntry(212) + " " + name);
                 mainapp->ShowNotification(set::GetDictionaryEntry(214) + " \'" + name + "\'.");
             }
             else HandleResult(rc, set::GetDictionaryEntry(215));
         }
         else mainapp->ShowNotification(set::GetDictionaryEntry(249));
     }
 }
Exemplo n.º 28
0
void CaptureCAM_XIMEA::init()
{
    stat = xiGetNumberDevices(&numDevices);
//     cout << "Number of connected devices: " << numDevices << endl;
    HandleResult(stat,"xiGetNumberDevices (no camera found)");
    try{
        if (!numDevices)
        {
            throw "No camera found\n";
        }
        hmv = NULL;
        isopened=false;
        timeout = 0;
        memset(&image, 0, sizeof(XI_IMG));
    }catch(const char* e){
        cout<< "An Exception occured. Exception: "<<e<<endl;
        close();
    }
}
Exemplo n.º 29
0
std::vector<CameraInfo> CameraXIMEA::getCameraList(){

    XI_RETURN stat = XI_OK;
    DWORD numCams;
    stat = xiGetNumberDevices(&numCams);
    HandleResult(stat, "xiGetNumberDevices");

    std::vector<CameraInfo> ret(numCams);
    for(unsigned int i=0; i<numCams; i++){
        CameraInfo info;
        info.vendor = "Ximea";
        char name[20];
        xiGetDeviceInfoString(i, XI_PRM_DEVICE_NAME, name, 20);
        info.model = name;
        info.busID = i;
        ret[i] = info;
    }
    return ret;
}
void RequestAdvertController::WomanListAdvertCallbackHandle(long requestId, const string& url, bool requestRet, const char* buf, int size)
{
	AdWomanListAdvertItem item;
	string errnum = "";
	string errmsg = "";
	bool bFlag = false;

	if (requestRet) {
		// request success
		Json::Value dataJson;
		if( HandleResult(buf, size, errnum, errmsg, &dataJson) ) {
			if (dataJson.isObject()) {
				bFlag = item.Parsing(dataJson);
			}

			if (!bFlag) {
				// parsing fail
				errnum = LOCAL_ERROR_CODE_PARSEFAIL;
				errmsg = LOCAL_ERROR_CODE_PARSEFAIL_DESC;

				FileLog("httprequest", "RequestAdvertController::WomanListAdvertCallbackHandle() parsing fail:"
						"(url:%s, size:%d, buf:%s)",
						url.c_str(), size, buf);
			}
		}
	}
	else {
		// request fail
		errnum = LOCAL_ERROR_CODE_TIMEOUT;
		errmsg = LOCAL_ERROR_CODE_TIMEOUT_DESC;
	}

	if( m_Callback.onRequestAdWomanListAdvert != NULL ) {
//        item.advertId = "advertId";
//        item.image = "image";
//        item.height = 15;
//        item.width = 12;
//        item.adurl = "adurl";
//        item.openType = AD_OT_SYSTEMBROWER;
		m_Callback.onRequestAdWomanListAdvert(requestId, bFlag, errnum, errmsg, item);
	}
}