コード例 #1
0
	Logger& Engine::out(LogLevel level) {
		switch (level)
		{
			case LogLevel::SPAM:
				*(Instance->SpamLogger) << getTimeStamp() << " [S]";
				return *(Instance->SpamLogger);
				break;

			case LogLevel::INFO:
				*(Instance->SpamLogger) << getTimeStamp() << " [I]";
				return *(Instance->InfoLogger);
				break;

			case LogLevel::WARNING:
				*(Instance->SpamLogger) << getTimeStamp() << " [W]";
				return *(Instance->WarningLogger);
				break;

			case LogLevel::ERROR:
				*(Instance->SpamLogger) << getTimeStamp() << " [E]";
				return *(Instance->ErrorLogger);
				break;

			default:
				*(Instance->SpamLogger) << getTimeStamp() << " [S]";
				return *(Instance->SpamLogger);
				break;
		}
	}
コード例 #2
0
ファイル: tools.cpp プロジェクト: BakeTheBeans/GUI
std::vector<DirectoryInfo> Directory :: getDirectoryContents(std::string _path)
{
    dirent * directoryStruct = 0;
    std::vector<DirectoryInfo> infoList;
    DIR * curDir = opendir(_path.c_str());
    if ( curDir == 0)  throw "Could not open the directory";


    while( (directoryStruct = readdir(curDir)) )
    {
        infoList.push_back(DirectoryInfo());
        DirectoryInfo & info = infoList[infoList.size()-1];
        info.fileName = std::string(directoryStruct->d_name);
        info.basePath = _path;
        std::string subPath = _path + "/" + std::string(info.fileName);

        struct stat bufStat;
        lstat( subPath.c_str(), &bufStat );

        info.size = bufStat.st_size;
        info.type = getFileType(&bufStat);

        info.lastAccessTime = getTimeStamp( bufStat.st_atim.tv_sec );
        info.lastModTime = getTimeStamp(( bufStat.st_mtim.tv_sec));

    }

    return infoList;
}
コード例 #3
0
ファイル: qtplayer.cpp プロジェクト: se210/tracy
static void playTrace(PlayerState* state)
{
    /* Start timing after the first actually rendered frame */
    if (!state->startTime /*&& state->frame == 2*/)
    {
        state->startTime = getTimeStamp();
    }

    if (!state->done)
    {
        state->done = (playFrame(state, state->frame) == 0);

        printf("Frame %d\n", state->frame);
        ASSERT_EGL;
        ASSERT_GL;

        if (state->frame > 0)
        {
#if defined(TAKE_SCREENSHOTS)
            takeScreenshot(state->frame, 0);
#endif
        }
        state->frame++;

        if (state->done)
        {
            int diff = getTimeStamp() - state->startTime;
            if (diff)
            {
                float fps = (1000000.0f * state->frame) / diff;
                printf("Average FPS: %.02f\n", fps);
            }
        }
    }
}
コード例 #4
0
ファイル: sdlstub.cpp プロジェクト: AliSayed/MoSync
void MoSyncStub::sleep(uint32 duration) {
	uint32 startTime = getTimeStamp();
	do {
		uint32 curTime = getTimeStamp() - startTime;
		if(curTime>=duration) break;
		maWait(duration-curTime);
	} while(true);
}
コード例 #5
0
ファイル: oauthlib.cpp プロジェクト: moodboom/Reusable
bool oAuth::getEtradeHeader(
    const eOAuthHttpRequestType eType, /* in */
    const std::string& rawUrl, /* in */
    const std::string& rawData, /* in */
    std::string& oAuthHttpHeader, /* out */
    const bool includeOAuthVerifierPin, /* in */
    const bool includeOAuthTokenPin /* in */
) {
    bool b_return = getOAuthHeader( eType, rawUrl, rawData, oAuthHttpHeader, includeOAuthVerifierPin );

    // Build the header in the only field order that I know that works with E*Trade's API.  Id10ts.
    if (includeOAuthVerifierPin)
    {
        oAuthHttpHeader =
              string("Authorization: OAuth oauth_nonce=\"")
            + getNonce()
            + "\",oauth_timestamp=\""
            + getTimeStamp()
            + "\",oauth_consumer_key=\""
            + getConsumerKey()
            + "\",oauth_token=\""
            + m_oAuthTokenKey
            + "\",oauth_verifier=\""
            + m_oAuthPin
            + "\",oauth_signature_method=\"HMAC-SHA1\",oauth_signature=\""
            + getOAuthSignature()
            + "\"\r\n";
    } else if (includeOAuthTokenPin)
    {
        oAuthHttpHeader =
              string("Authorization: OAuth oauth_nonce=\"")
            + getNonce()
            + "\",oauth_timestamp=\""
            + getTimeStamp()
            + "\",oauth_consumer_key=\""
            + getConsumerKey()
            + "\",oauth_token=\""
            + m_oAuthTokenKey
            + "\",oauth_signature_method=\"HMAC-SHA1\",oauth_signature=\""
            + getOAuthSignature()
            + "\"\r\n";
    } else
    {
        oAuthHttpHeader =
              string("Authorization: OAuth oauth_nonce=\"")
            + getNonce()
            + "\",oauth_timestamp=\""
            + getTimeStamp()
            + "\",oauth_consumer_key=\""
            + getConsumerKey()
            + "\",oauth_callback=\"oob\",oauth_signature_method=\"HMAC-SHA1\",oauth_signature=\""
            + getOAuthSignature()
            + "\"\r\n";
    }

    return b_return;
}
コード例 #6
0
ファイル: pcapport.cpp プロジェクト: dancollins/ostinato
int PcapPort::PortTransmitter::sendQueueTransmit(pcap_t *p,
        pcap_send_queue *queue, long &overHead, int sync)
{
    TimeStamp ovrStart, ovrEnd;
    struct timeval ts;
    struct pcap_pkthdr *hdr = (struct pcap_pkthdr*) queue->buffer;
    char *end = queue->buffer + queue->len;

    ts = hdr->ts;

    getTimeStamp(&ovrStart);
    while((char*) hdr < end)
    {
        uchar *pkt = (uchar*)hdr + sizeof(*hdr);
        int pktLen = hdr->caplen;

        if (sync)
        {
            long usec = (hdr->ts.tv_sec - ts.tv_sec) * 1000000 +
                (hdr->ts.tv_usec - ts.tv_usec);

            getTimeStamp(&ovrEnd);

            overHead -= udiffTimeStamp(&ovrStart, &ovrEnd);
            Q_ASSERT(overHead <= 0);
            usec += overHead;
            if (usec > 0)
            {
                udelay(usec);
                overHead = 0;
            }
            else
                overHead = usec;

            ts = hdr->ts;
            getTimeStamp(&ovrStart);
        }

        Q_ASSERT(pktLen > 0);

        pcap_sendpacket(p, pkt, pktLen);
        stats_->txPkts++;
        stats_->txBytes += pktLen;

        // Step to the next packet in the buffer
        hdr = (struct pcap_pkthdr*) (pkt + pktLen);
        pkt = (uchar*) ((uchar*)hdr + sizeof(*hdr));

        if (stop_)
        {
            return -2;
        }
    }

    return 0;
}
コード例 #7
0
ファイル: DSPProcessor_OEM.c プロジェクト: richardxu/panda-a4
/*
 *  ======== DSPProcessor_Load ========
 *  Purpose:
 *      Reset a processor and load a new base program image.
 *      This will be an OEM-only function, and not part of the 'Bridge
 *      application developer's API.
 */
DBAPI DSPProcessor_Load(DSP_HPROCESSOR hProcessor, IN CONST INT iArgc,
                        IN CONST CHAR **aArgv, IN CONST CHAR **aEnvp)
{
    DSP_STATUS status = DSP_SOK;
    Trapped_Args tempStruct;
#ifdef DEBUG_BRIDGE_PERF
    struct timeval tv_beg;
    struct timeval tv_end;
    struct timezone tz;
    int timeRetVal = 0;

    timeRetVal = getTimeStamp(&tv_beg);
#endif


    DEBUGMSG(DSPAPI_ZONE_FUNCTION, (TEXT("PROC: DSPProcessor_Load\r\n")));

    /* Check the handle */
    if (hProcessor) {
        if (iArgc > 0) {
            if (!DSP_ValidReadPtr(aArgv, iArgc)) {
                tempStruct.ARGS_PROC_LOAD.hProcessor =
                    hProcessor;
                tempStruct.ARGS_PROC_LOAD.iArgc = iArgc;
                tempStruct.ARGS_PROC_LOAD.aArgv =
                    (CHAR **)aArgv;
                tempStruct.ARGS_PROC_LOAD.aEnvp =
                    (CHAR **)aEnvp;
                status = DSPTRAP_Trap(&tempStruct,
                                      CMD_PROC_LOAD_OFFSET);
            } else {
                status = DSP_EPOINTER;
                DEBUGMSG(DSPAPI_ZONE_ERROR,
                         (TEXT("PROC: Null pointer in input \r\n")));
            }
        } else {
            status = DSP_EINVALIDARG;
            DEBUGMSG(DSPAPI_ZONE_ERROR,
                     (TEXT("PROC: iArgc is invalid. \r\n")));
        }
    } else {
        /* Invalid handle */
        status = DSP_EHANDLE;
        DEBUGMSG(DSPAPI_ZONE_ERROR,
                 (TEXT("PROC: Invalid Handle \r\n")));
    }

#ifdef DEBUG_BRIDGE_PERF
    timeRetVal = getTimeStamp(&tv_end);
    PrintStatistics(&tv_beg, &tv_end, "DSPProcessor_Load", 0);

#endif

    return status;
}
コード例 #8
0
ファイル: ue03.c プロジェクト: ninaa123/ue03
////////////////////////////////////////////////////////////////////////////////
// MAIN
////////////////////////////////////////////////////////////////////////////////
int main( int argc, char *argv[] ) {
    /*################ PREPERATIONS (boring) ################*/
    /* declarations */
    unsigned int    boxcount,       //how many boxes there are
                    repetitions,    //how many experiments to be made
                    *boxes,         //contents of each box
                    i, j,           //iterators
                    tmpwalk=0;        //coordinate of current iteration
    double          time;           //time for clocking the program
    double prob;
    
    /* argument handling */
    if(argc<3) {
        printf("Usage: %s repetitions boxes\n", argv[0]);
        return -1;
    }
    repetitions = (unsigned)atof(argv[1]); // atof to use shorthand such as 1e7
    boxcount    = (unsigned)atof(argv[2]);
    prob    = atof(argv[3]);
    /* allocate memory for boxes */
    boxes = (unsigned*) calloc(boxcount, sizeof(boxes));        //boxen für galton-brett 
    /* get the start time */
    time = getTimeStamp();                                      //start des "stoppen"
    /* seed random number generator */
    srand((int)time);                                           //initialisierung fürs rand

    /*################ ACTUAL SIMULATION ################*/
    for( i=0; i<repetitions; ++i ) {                            //also repetitions is praktisch die anzahl der zeilen von dem galton board?
        tmpwalk = 0;                                            //aktueller box index?
        for( j=0; j<boxcount-1; ++j )
            tmpwalk += randoffset(prob);                        //zu tmpwalk werden immer 0 und 1 addiert- je nachdem.. wozu?!
        ++boxes[tmpwalk];
    }                                                           //zusammenfassung: i versteh ned wozu die zeile mit tmpwalk+=randoffset() is.. =/

    
    /*#################### CLEAN UP #####################*/
    time = getTimeStamp()-time;
    printf(
        "runtime %g\n"
        "iterations %g\n"
        "boxes %g\n"
        "\n",
        time, (double)i, (double)boxcount
    );
    /* output and exiting */
    for( i=0; i<(unsigned)argc; ++i)
        if( argv[i][0] == 'n' ) goto skipoutput;
    for( i=0; i<boxcount; ++i)
        printf("%d\t%d\n",i,boxes[i]);

    skipoutput:
        free(boxes);
        return 0;
}
コード例 #9
0
/*!  \brief Open log file
 *
 *  @param description - Description written to log file
 *
 *  @note logging is enabled and timestamp disabled
 */
void Logging::openLogFile(const char *description) {

   indent = 0;
   currentName = NULL;

   time_t time_now;
   time(&time_now);

   if (logFile != NULL) {
      loggingEnabled   = true;
      fprintf(logFile, "Log re-opened on: %s"
            "==============================================\n\n", ctime(&time_now));
      return;
   }
   logFile = openApplicationFile("usbdm.log");
   if (logFile == NULL) {
      return;
   }
   loggingEnabled     = true;
   timestampMode      = incremental;
   getTimeStamp();

   fprintf(logFile, "%s - %s, Compiled on %s, %s.\n",
         description,
         USBDM_VERSION_STRING, __DATE__,__TIME__);

   fprintf(logFile, "Log file created on: %s"
         "==============================================\n\n", ctime(&time_now));

   // Re-direct stderr to logfile
   dup2(fileno(logFile), STDERR_FILENO);
}
コード例 #10
0
void PhysicsSpace::produceCollision(const CollisionEventType::slot_type* listener, 
                                    const Pnt3f& Position,
                                    const Vec3f& Normal, 
                                    PhysicsGeom* const Geom1,
                                    PhysicsGeom* const Geom2,
                                    UInt64 Geom1Cat,
                                    UInt64 Geom1Col,
                                    UInt64 Geom2Cat,
                                    UInt64 Geom2Col,
                                    const Vec3f& Velocity1,
                                    const Vec3f& Velocity2,
                                    const Real32& ProjectedNormalSpeed)
{
    CollisionEventDetailsUnrecPtr Details = CollisionEventDetails::create(this,
                                                                          getTimeStamp(),
                                                                          Position,
                                                                          Normal,
                                                                          Geom1,
                                                                          Geom2,
                                                                          Geom1Cat,
                                                                          Geom1Col,
                                                                          Geom2Cat,
                                                                          Geom2Col,
                                                                          Velocity1,
                                                                          Velocity2,
                                                                          ProjectedNormalSpeed);

    (*listener)(Details, CollisionEventId);
   
    Inherited::produceCollision(Details);
}
コード例 #11
0
baci::ActionRequest 
SimpleBACIComponent::invokeAction(int function,
				  baci::BACIComponent *cob_p, 
				  const int &callbackID, 
				  const CBDescIn &descIn, 
				  baci::BACIValue *value_p, 
				  Completion &completion, 
				  CBDescOut &descOut) 
{
    switch(function) 
	{
	case ACTION:
	{
	    ACS_DEBUG_PARAM("::SimpleBACIComponent::Action", "%s", getComponent()->getName());
    
	    completion.timeStamp = getTimeStamp();
	    completion.type=ACSErr::ACSErrTypeOK;
	    completion.code = ACSErrTypeOK::ACSErrOK;

	    return baci::reqInvokeDone;
	}
	default:
	    return baci::reqDestroy;
	}
}
コード例 #12
0
ファイル: clientSender.cpp プロジェクト: aliyawar/AlterEgo
int main(int argc, char** argv)
{
  signal ( SIGINT, signal_callback_handler );

  AlterEgoClient::ClientType t = AlterEgoClient::AVATARCONTROL;
  if (argc == 3)
    t = AlterEgoClient::GAMESTATE;

  AlterEgoClient client(argv[1], t);
  client.start();

  double pos = 0;
  AlterEgo::GameState gs(1);

  while (running)
  {
    pos += 0.01;
    gs.setTime(getTimeStamp());
    gs.setBallX((1+sin(pos))/2);
    client.send(&gs);
    usleep(1000);
  }
  client.stop();
  std::cout << "clean exit" << std::endl;

  return 0;
}
コード例 #13
0
ファイル: Lx200EMCVelDevIO.cpp プロジェクト: javarias/csat
Lx200EMCVelDevIO::Lx200EMCVelDevIO(char *deviceName, int axis, bool reversed) throw (csatErrors::CannotOpenDeviceEx)
{
		  char *_METHOD_=(char *)"Lx200EMCVelDevIO::Lx200EMCVelDevIO";
		  ACS::Time time = getTimeStamp();
		  CORBA::Double initialSlewRate(0.0);

		  try{
					 this->sp = new SerialRS232(deviceName,100);
		  } catch(SerialRS232::SerialRS232Exception serialEx) {
					 ACS_LOG( LM_ERROR , _METHOD_ , (LM_ERROR, "CannotOpenDeviceEx: %s", serialEx.what()) );
					 csatErrors::CannotOpenDeviceExImpl ex(__FILE__,__LINE__,_METHOD_);
					 ex.addData("Reason",serialEx.what());
					 throw ex.getCannotOpenDeviceEx();
		  }

		  /* Check telescope connection by setting initial slew rate */
		  try{
					this->axis = axis;
					write(initialSlewRate, time);

		  } catch(SerialRS232::SerialRS232Exception serialEx) {
					 csatErrors::CannotOpenDeviceExImpl ex(__FILE__,__LINE__,_METHOD_);
					 ex.addData("Reason",serialEx.what());
					 throw ex.getCannotOpenDeviceEx();
		  }

	if(this->axis == ALTITUDE_AXIS)
      this->slewRateElevation = 0;
   else
      this->slewRateAzimuth = 0;
	this->reversed = reversed;
}
コード例 #14
0
ファイル: chattextedit.cpp プロジェクト: BearWare/TeamTalk5
void ChatTextEdit::updateServer(const ServerProperties& srvprop)
{
    appendPlainText("");

    QString dt = getTimeStamp();
    
    QTextCharFormat format = textCursor().charFormat();
    QTextCharFormat original = format;
    QTextCursor cursor = textCursor();
    
    //show 'joined new channel' in bold
    QFont font = format.font();
    font.setBold(true);
    format.setFont(font);
    cursor.setCharFormat(format);
    QString line = dt + tr("Server Name: %1").arg(_Q(srvprop.szServerName));;
    setTextCursor(cursor);
    appendPlainText(line);

    line = dt + tr("Message of the Day: %1").arg(_Q(srvprop.szMOTD)) + "\r\n";
    format.setForeground(QBrush(Qt::darkCyan));
    cursor.setCharFormat(format);
    setTextCursor(cursor);
    appendPlainText(line);

    //revert bold
    font.setBold(false);
    format.setFont(font);

    //revert to original
    cursor.setCharFormat(original);
    setTextCursor(cursor);
    limitText();
}
コード例 #15
0
/*!  \brief Open log file
 *
 *  @param logFileName - Name of log file
 *  @param description - Description written to log file
 *
 *  @note logging is enabled and timestamp disabled
 */
void Logging::openLogFile(const char *logFileName, const char *description){

   indent = 0;
   currentName = NULL;
   if (logFile != NULL) {
      fclose(logFile);
   }
   logFile = openApplicationFile(logFileName, "wt");
#ifdef _WIN32
   if (logFile == NULL) {
      logFile = fopen("C:\\Documents and Settings\\PODonoghue\\Application Data\\usbdm\\xx.log", "wt");
//         print("openLogFile() - failed to open %s\n", logFileName);
   }
#endif
   if (logFile == NULL) {
      return;
   }
   loggingEnabled     = true;
   timestampMode      = incremental;
   getTimeStamp();

   fprintf(logFile, "%s - %s, Compiled on %s, %s.\n",
         description,
         USBDM_VERSION_STRING, __DATE__,__TIME__);

   time_t time_now;
   time(&time_now);
   fprintf(logFile, "Log file created on: %s"
         "==============================================\n\n", ctime(&time_now));
}
コード例 #16
0
ファイル: stdoutsub.c プロジェクト: ngocphu811/RasPi-mqtt-c
int readMeasures()
{
	int temperature   = getTemperature();
	double humidity   = getHumidity();
	double luminosity = getLuminosity() ;

	char str[250];
	sprintf(str," temperature=%d, humidity=%lf, luminosity=%lf",  temperature, humidity, luminosity);
	printf("[Entry_point] Reading measures : %s\n", str);

	/*payload =
		"["
	    "{"
	    "\"machine.temperature\": [{"
	    "  \"timestamp\" : %d, "
	    "  \"value\" : \"%lf\""
	    "}]"
	    "}"
	    "]";*/
	int timestamp = getTimeStamp();
	temp_ts[temp_size] = timestamp;
	temp_values[temp_size] = malloc(10);
	sprintf(temp_values[temp_size], "%d", temperature);
	temp_size++;

	hum_ts[hum_size] = timestamp;
	hum_values[hum_size] = malloc(10);
	sprintf(hum_values[hum_size], "%lf", humidity);
	hum_size++;

	return 0;
}
コード例 #17
0
ファイル: baciBACIMonitor.cpp プロジェクト: ACS-Community/ACS
void BACIMonitor::setTriggerTime(const ACS::TimeInterval& _triggerTime)
{
  ACS_TRACE("baci::BACIMonitor::setTriggerTime");
  if (_triggerTime != triggerTime_m)
    {
      if (_triggerTime<=0)
	  {
	  triggerTime_m=0;
	  }
      else if (_triggerTime < minTriggerTime_m)
	  {
	  triggerTime_m=minTriggerTime_m; 
	  }
      else 
	  {
	  triggerTime_m=_triggerTime;
	  }

      setLastTime(getTimeStamp()-getTriggerTime());

      if((triggerOnValue_m == true || triggerOnValuePercent_m == true) && triggerTime_m > 0)
        deltaValueAndTimerInteraction_m = true;
      else
        deltaValueAndTimerInteraction_m = false;
      monitorStateChanged();
      property_mp->updateMonitorStates();
    }
}
コード例 #18
0
ファイル: helper.c プロジェクト: kkoo/cs426
unsigned char *createX0(char *authKey) {
	//x0 = p, d, Cu, A0
	char *p = intToStr( 1 );
	char *d = intToStr( getTimeStamp() );

	//read the certificate
	unsigned char *Cu;
	char *cert;

	FILE *fp=fopen(certFile, "rb");
	if (fp == NULL) {
  		fprintf(stderr, "Cannot open Certificate File\n");
  		exit(1);
	}
	fseek(fp,0,SEEK_END);
   	int length = ftell (fp);
   	rewind(fp);

	cert = (char *) malloc (length + 1);
	fread(cert,sizeof(char),length,fp);
	cert[length] = '\0';

	close(fp);
	//end read CERT

	char *retStr = (char *)malloc( strlen(p) + strlen(d) + strlen(cert) + strlen(authKey) + 1);
	strcpy(retStr, p); free(p);
	strcat(retStr, d); free(d);
	strcat(retStr, cert); free(cert);
	strcat(retStr, authKey); 
	strcat(retStr, "\0");

	return retStr;
}
コード例 #19
0
/** Called when asyn clients call pasynFloat64Array->read().
  * Returns the value of the P_Waveform or P_TimeBase arrays.  
  * \param[in] pasynUser pasynUser structure that encodes the reason and address.
  * \param[in] value Pointer to the array to read.
  * \param[in] nElements Number of elements to read.
  * \param[out] nIn Number of elements actually read. */
asynStatus testAsynPortDriver::readFloat64Array(asynUser *pasynUser, epicsFloat64 *value, 
                                         size_t nElements, size_t *nIn)
{
    int function = pasynUser->reason;
    size_t ncopy;
    int itemp;
    asynStatus status = asynSuccess;
    epicsTimeStamp timeStamp;
    const char *functionName = "readFloat64Array";

    getTimeStamp(&timeStamp);
    pasynUser->timestamp = timeStamp;
    getIntegerParam(P_MaxPoints, &itemp); ncopy = itemp;
    if (nElements < ncopy) ncopy = nElements;
    if (function == P_Waveform) {
        memcpy(value, pData_, ncopy*sizeof(epicsFloat64));
        *nIn = ncopy;
    }
    else if (function == P_TimeBase) {
        memcpy(value, pTimeBase_, ncopy*sizeof(epicsFloat64));
        *nIn = ncopy;
    }
    if (status) 
        epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, 
                  "%s:%s: status=%d, function=%d", 
                  driverName, functionName, status, function);
    else        
        asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, 
              "%s:%s: function=%d\n", 
              driverName, functionName, function);
    return status;
}
コード例 #20
0
ファイル: temp.c プロジェクト: luisperestrelo/SETEC-Pandlets
uint32_t temp_values_handler() {
	uint32_t  err_code = NRF_SUCCESS;
	int32_t temp_buffer;

	err_code = bme280_read_temperature(&temp_buffer);

	if (err_code != NRF_SUCCESS) {
//		temp_printf("temp: bme280_read_temperature() failed.\r\n");
		return err_code;
	}
	

	char val[20];
	char time_val[20];
	add_zeroes((int)temp_buffer, val);
	add_zeroes((int)getTimeStamp(), time_val);
	char buf[20];
	sprintf(buf, "\n%d,%s,%s", DEVICE_ID,time_val,val);
    
	log2sd(buf, "READINGS.txt");
   // temp_printf("li\n");    
//	temp_printf("Temperature: %d\n", (int)temp_buffer);
	err_code = ble_ambient_sensor_update(m_temp.m_amb, (uint8_t *) &temp_buffer,
	AMB_TEMP_MAX_PACKET_VALUE, BLE_AMBIENT_TEMP);
	check_ble_service_err_code(err_code);

	return NRF_SUCCESS;
}
コード例 #21
0
ファイル: log.cpp プロジェクト: cglogic/collector
void Log::writeMessage(EMessageType type, const QString& message)
{
	(*fileStream) << getTimeStamp() << "  ";

	switch (type)
	{
	case MT_INFO:
		(*fileStream) << QObject::tr("Info: ");
		break;

	case MT_WARN:
		(*fileStream) << QObject::tr("Warning: ");
		break;

	case MT_CRIT:
		(*fileStream) << QObject::tr("Critical: ");
		break;

	default:
		(*fileStream) << QObject::tr("Unknown: ");
		break;
	}

	(*fileStream) << message << "\n";
	fileStream->flush();
	file->flush();

	if (type == MT_WARN || type == MT_CRIT)
	{
		(*consoleStream) << message << "\n";
		consoleStream->flush();
	}
}
コード例 #22
0
ファイル: testErrors.cpp プロジェクト: ffeldbauer/asyn
asynStatus testErrors::doReadArray(asynUser *pasynUser, epicsType *value, 
                                   size_t nElements, size_t *nIn, int paramIndex, epicsType *pValue)
{
    int function = pasynUser->reason;
    size_t ncopy = MAX_ARRAY_POINTS;
    int status = asynSuccess;
    epicsTimeStamp timestamp;
    const char *functionName = "doReadArray";

    /* Get the current error status */
    getIntegerParam(P_StatusReturn, &status);
    
    /* Get the current timestamp */
    getTimeStamp(&timestamp);
    pasynUser->timestamp = timestamp;

    if (nElements < ncopy) ncopy = nElements;
    if (function == paramIndex) {
        memcpy(value, pValue, ncopy*sizeof(epicsType));
        *nIn = ncopy;
    }

    if (status) 
        epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, 
                  "%s:%s: status=%d, function=%d", 
                  driverName, functionName, status, function);
    else        
        asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, 
              "%s:%s: function=%d\n", 
              driverName, functionName, function);
    return (asynStatus)status;
}
コード例 #23
0
ファイル: MiniDump.cpp プロジェクト: ueverything/easyserver
	LONG WINAPI MyUnhandledExceptionFilter(struct _EXCEPTION_POINTERS* ExceptionInfo)
	{
		// 先生成目录
		easygame::Platform::createDirectorys(g_dumpPath.c_str());

		// 输出minidump文件
		string timestamp = getTimeStamp();
		string strFilePrev = g_dumpPath;
		strFilePrev += g_dumpName;
		strFilePrev += "_";
		strFilePrev += timestamp;
		string strDumpFile = strFilePrev;
		strDumpFile += ".dmp";
		HANDLE lhDumpFile = CreateFile(strDumpFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL ,NULL);
		MINIDUMP_EXCEPTION_INFORMATION loExceptionInfo;
		loExceptionInfo.ExceptionPointers = ExceptionInfo;
		loExceptionInfo.ThreadId = GetCurrentThreadId();
		loExceptionInfo.ClientPointers = TRUE;
		MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(),lhDumpFile, MiniDumpNormal, &loExceptionInfo, NULL, NULL);
		CloseHandle(lhDumpFile);

		// 日志文件
		string strStackFile = strFilePrev;
		strStackFile += ".txt";
		FileStackWalker fsw(strStackFile.c_str());
		fsw.ShowCallstack(GetCurrentThread(), ExceptionInfo->ContextRecord);

		return EXCEPTION_EXECUTE_HANDLER;
	}
コード例 #24
0
ファイル: acstimeProfiler.cpp プロジェクト: ACS-Community/ACS
//------------------------------------------------------------------------------
ACS::Time
Profiler::stop()
{
    //save the current time
    if (lastStart_m==0)
	{
	std::cerr << "Looks like Profiler::stop was called twice in a row without invoking Profiler::start" << std::endl;
	return 0ULL;
	}
    ACS::Time timeDiff = getTimeStamp() - lastStart_m;

    if (timeDiff>maxDuration)
	{
	maxDuration=timeDiff;
	}

    if (timeDiff<minDuration)
	{
	minDuration=timeDiff;
	}

    //0 last value
    lastStart_m=0;

    //add this to the total time
    totalTime += timeDiff;
    
    return timeDiff;
}
コード例 #25
0
void Logger::logMessage(std::string theLog)
{
	mtx.lock();
	std::string timestamp = getTimeStamp();
	std::cout << timestamp << "- " << theLog << std::endl;
	mtx.unlock();
}
コード例 #26
0
/*
 *  ======== DSPNode_PutMessage ========
 *  Purpose:
 *      Send an event message to a task node.
 */
DBAPI DSPNode_PutMessage(DSP_HNODE hNode, IN CONST struct DSP_MSG *pMessage,
						UINT uTimeout)
{
	DSP_STATUS status = DSP_SOK;
	Trapped_Args tempStruct;
#ifdef DEBUG_BRIDGE_PERF
	struct timeval tv_beg;
	struct timeval tv_end;
	struct timeval tz;
	int timeRetVal = 0;

	timeRetVal = getTimeStamp(&tv_beg);
#endif

	DEBUGMSG(DSPAPI_ZONE_FUNCTION, (TEXT("NODE: DSPNode_PutMessage:\r\n")));

	if (hNode) {
		if (pMessage) {
			/* Set up the structure */
			/* Call DSP Trap */
			tempStruct.ARGS_NODE_PUTMESSAGE.hNode = hNode;
			tempStruct.ARGS_NODE_PUTMESSAGE.pMessage =
						(struct DSP_MSG *)pMessage;
			tempStruct.ARGS_NODE_PUTMESSAGE.uTimeout = uTimeout;
			status = DSPTRAP_Trap(&tempStruct,
				CMD_NODE_PUTMESSAGE_OFFSET);
		} else {
			status = DSP_EPOINTER;
			DEBUGMSG(DSPAPI_ZONE_ERROR,
				(TEXT("NODE: DSPNode_PutMessage: "
						"pMessage is Invalid \r\n")));
		}
	} else {
		/* Invalid pointer */
		status = DSP_EHANDLE;
		DEBUGMSG(DSPAPI_ZONE_ERROR,
			(TEXT("NODE: DSPNode_PutMessage: "
					"hNode is Invalid \r\n")));
	}
#ifdef DEBUG_BRIDGE_PERF
	timeRetVal = getTimeStamp(&tv_end);
	PrintStatistics(&tv_beg, &tv_end, "DSPNode_PutMessage", 0);
#endif


	return status;
}
コード例 #27
0
ファイル: NBody.cpp プロジェクト: GMAC-lib/gmac
/**
* @brief OpenGL display function
*/
void displayfunc()
{
    gmactime_t s, t;
    getTime(&s);
    frameCount++;

    glClearColor(0.0 ,0.0, 0.0, 0.0);
    glClear(GL_COLOR_BUFFER_BIT);
    glClear(GL_DEPTH_BUFFER_BIT);

    glPointSize(1.0);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE);
    glEnable(GL_BLEND);
    glDepthMask(GL_FALSE);

    glColor3f(1.0f,0.6f,0.0f);

    //Calling kernel for calculatig subsequent positions
    ((NBody*)me)->runCLKernels();

    glBegin(GL_POINTS);
    for(int i=0; i < numBodies; ++i)
    {
        //divided by 300 just for scaling
        glVertex3d(pos[i*4+ 0]/300, pos[i*4+1]/300, pos[i*4+2]/300);
    }
    glEnd();

    glFlush();
    glutSwapBuffers();

    getTime(&t);
    totalElapsedTime += (getTimeStamp(t) - getTimeStamp(s)); //(double)(t2 - t1);
    if(frameCount > frameRefCount) {
        // set GLUT Window Title
        char title[256];
        int framesPerSec = (int)(frameCount / (totalElapsedTime / 1e6));
#if defined (_WIN32) && !defined(__MINGW32__)
        sprintf_s(title, 256, "OpenCL NBody | %d fps ", framesPerSec);
#else 
        sprintf(title, "OpenCL NBody | %d fps", framesPerSec);
#endif
        glutSetWindowTitle(title);
        frameCount = 0;
        totalElapsedTime = 0.0;
    }
}
コード例 #28
0
bool NTScalar::attachTimeStamp(PVTimeStamp &pvTimeStamp) const
{
    PVStructurePtr ts = getTimeStamp();
    if (ts)
        return pvTimeStamp.attach(ts);
    else
        return false;
}
コード例 #29
0
ファイル: rpicamera.cpp プロジェクト: dreamfrog/robocup
NUImage* RPiCamera::grabNewImage()
{
    while(!capturedNew());
    currentBufferedImage.MapYUV422BufferToImage(getImage(), WIDTH, HEIGHT, true);
    currentBufferedImage.setTimestamp(getTimeStamp());
    currentBufferedImage.setCameraSettings(m_settings);
    return &currentBufferedImage;
}
コード例 #30
0
/*
 *  ======== DSPNode_GetMessage ========
 *  Purpose:
 *      Retrieve an event message from a task node.
 */
DBAPI DSPNode_GetMessage(DSP_HNODE hNode, OUT struct DSP_MSG *pMessage,
				UINT uTimeout)
{
	int status = 0;
	Trapped_Args tempStruct;
#ifdef DEBUG_BRIDGE_PERF
	struct timeval tv_beg;
	struct timeval tv_end;
	struct timezone tz;
	int timeRetVal = 0;

	timeRetVal = getTimeStamp(&tv_beg);

#endif

	DEBUGMSG(DSPAPI_ZONE_FUNCTION, (TEXT("NODE: DSPNode_GetMessage:\r\n")));

	if (hNode) {
		if (pMessage) {
			/* Set up the structure */
			/* Call DSP Trap */
			tempStruct.ARGS_NODE_GETMESSAGE.hNode = hNode;
			tempStruct.ARGS_NODE_GETMESSAGE.pMessage = pMessage;
			tempStruct.ARGS_NODE_GETMESSAGE.uTimeout = uTimeout;
			status = DSPTRAP_Trap(&tempStruct,
				CMD_NODE_GETMESSAGE_OFFSET);
		} else {
			status = -EFAULT;
			DEBUGMSG(DSPAPI_ZONE_ERROR,
				(TEXT("NODE: DSPNode_GetMessage:"
				"pMessage is Invalid \r\n")));
		}
	} else {
		status = -EFAULT;
		DEBUGMSG(DSPAPI_ZONE_ERROR,
			(TEXT("NODE: DSPNode_GetMessage: "
			"hNode is Invalid \r\n")));
	}
#ifdef DEBUG_BRIDGE_PERF
	timeRetVal = getTimeStamp(&tv_end);
	PrintStatistics(&tv_beg, &tv_end, "DSPNode_GetMessage", 0);
#endif


	return status;
}