Example #1
0
    virtual void onTrace(const char* msg, const char* time, TraceLevel level)
    {
        assert(msg != NULL);

#if PLATFORM == PLATFORM_WIN32
        if (time && hasTime())
            std::cout<<time;
        std::cout<<msg;
#else
        static const char* color[] =
        {
            0,
            STD_COLOR_NONE,	    // Info
            STD_COLOR_GREEN,	// Trace
            0,
            STD_COLOR_PURPLE,	// Warning
            0,0,0,
            STD_COLOR_RED,		// Error
            0,0,0,0,0,0,0,
            STD_COLOR_EMPHASIS, // Emphasis
        };

        if (time && hasTime())
        {
            printf("%s%s", color[level], time);
        }
        printf("%s%s", color[level], msg);
        printf(STD_COLOR_NONE);
#endif
    }
Example #2
0
VariablesGrid VariablesGrid::getTimeSubGrid(	double startTime,
												double endTime
												) const
{
    uint startIdx = getCeilIndex( startTime );
	uint endIdx   = getFloorIndex( endTime );

	VariablesGrid newVariablesGrid;

	if ( ( isInInterval( startTime ) == BT_FALSE ) || ( isInInterval( endTime ) == BT_FALSE ) )
		return newVariablesGrid;
	
	if ( ( startIdx >= getNumPoints( ) ) || ( endIdx >= getNumPoints( ) ) )
		return newVariablesGrid;

// 	if ( startIdx > endIdx )
// 		return newVariablesGrid;
	
	// add all matrices in interval (constant interpolation)
	if ( ( hasTime( startTime ) == BT_FALSE ) && ( startIdx > 0 ) )
		newVariablesGrid.addMatrix( *(values[ startIdx-1 ]),startTime );
	
	for( uint i=startIdx; i<=endIdx; ++i )
		newVariablesGrid.addMatrix( *(values[i]),getTime( i ) );
	
	if ( hasTime( endTime ) == BT_FALSE )
		newVariablesGrid.addMatrix( *(values[ endIdx ]),endTime );

    return newVariablesGrid;
}
Example #3
0
    virtual void onTrace(const char* msg, const char* time, TraceLevel level)
    {
        if (!mHwnd)
            return;

        if (time && hasTime())
            addTraceToRichEdit(mHwnd, time, level);
        addTraceToRichEdit(mHwnd, msg, level);
    }
Example #4
0
    virtual void onTrace(const char* msg, const char* time, TraceLevel level)
    {
        assert(msg != NULL);

        static const char* color[] =
        {
            0,
            "<font color=\"#000000\">", // Info
            "<font color=\"#0000FF\">",	// Trace
            0,
            "<font color=\"#FF00FF\">",	// Warning
            0,0,0,
            "<font color=\"#FF0000\">",	// Error
            0,0,0,0,0,0,0,
            "<font color=\"#FFFF00\" style =\"background-color:#6a3905;\">", // Emphasis
        };

        fputs(color[(int)level], mFile);

        if (time && hasTime())
        {
            fputs(time, mFile);
        }

        char* pStart = (char *)msg;
        char* pPos = pStart;
        char* pEnd = pStart + strlen(pStart) - sizeof(char);

        while (pPos <= pEnd)
        {
            if (*pPos == '\n') // 换行
            {
                if (pStart < pPos)
                {
                    fwrite(pStart, pPos - pStart, 1, mFile);
                }
                fputs("<br>", mFile);

                pStart = ++pPos;
            }
            else
            {
                pPos ++;
            }
        }

        if (pStart < pPos)
            fwrite(pStart, pPos - pStart, 1, mFile);

        fputs("</font>\n", mFile);

        fflush(mFile);
    }
void VsRegistry::loadTime(VsGroup* group) {
  VsLog::debugLog() <<"VsRegistry::loadTime() - Group is NULL?" << "'" << group << "'" <<std::endl;
  if (!group) {
    VsLog::debugLog() <<"VsRegistry::loadTime() - Group is NULL?" <<std::endl;
    return;
  }
  
  //try to load a value for "time"
  double foundTime = -1.0;
  VsAttribute* timeAtt = group->getAttribute(VsSchema::timeAtt);
  if (timeAtt) {
    std::vector<float> in;
    int err = timeAtt->getFloatVectorValue(&in);
    if (err < 0) {
      VsLog::debugLog() <<"VsRegistry::loadTime(): Error " <<err <<" while trying to load time attribute." <<std::endl;
    } else {
      foundTime = in[0];
      VsLog::debugLog() <<"VsRegistry::loadTime() - loaded time: " <<foundTime  <<std::endl;
    }
  }

  //try to load a value for "cycle"
  int foundCycle = -1;
  VsAttribute* cycleAtt = group->getAttribute(VsSchema::cycleAtt);
  if (cycleAtt) {
    std::vector<int> in;
    int err = cycleAtt->getIntVectorValue(&in);
    if (err < 0) {
      VsLog::debugLog() <<"VsRegistry::loadTime(): Error " <<err <<" while trying to load cycle attribute." <<std::endl;
    } else {
      foundCycle = in[0];
      VsLog::debugLog() <<"VsRegistry::loadTime() - loaded cycle: " <<foundCycle <<std::endl;
    }
  }
 
  //check for existing time data, and compare
  if ((foundTime != -1) && hasTime() && (foundTime != getTime())) {
    VsLog::warningLog() <<"VsRegistry::loadTime() - was asked to load time data again, but time data already exists." <<std::endl;
    VsLog::warningLog() <<"VsRegistry::loadTime() - and is in conflict: " <<foundTime <<" vs " <<getTime() <<std::endl;
  } else {
    timeValue = foundTime;
  }
  
  if ((foundCycle != -1) && hasCycle() && (foundCycle != getCycle())) {
    VsLog::warningLog() <<"VsRegistry::loadTime() - was asked to load cycle data again, but cycle data already exists." <<std::endl;
    VsLog::warningLog() <<"VsRegistry::loadTime() - and is in conflict: " <<foundCycle <<" vs " <<getCycle() <<std::endl;
  } else {
    cycle = foundCycle;
  }
}
Example #6
0
void TimeManager::removeTime(guidType timeGuid) {
    assert( hasTime(timeGuid) || "given timeGuid doesn't exist");

    auto timeTuple = getTimeTuple(timeGuid);
    if (hasActiveTime(timeGuid)) {
	activeTimeContainer.erase(timeTuple);
    }
    else if (hasInactiveTime(timeGuid)) {
	inActiveTimeContainer.erase(timeTuple);
    }
    else {
	std::cerr << "Warning: given timeGuid " << timeGuid << " DNE" << std::endl;
    }
}
Example #7
0
void Support::registerFields(Stage& stage, Schema& schema, PointFormat format)
{
    std::ostringstream text;

    std::vector<pdal::Dimension> const& d = stage.getDefaultDimensions();

    Schema dimensions(d);

    schema.appendDimension(dimensions.getDimension("X", stage.getName()));
    schema.appendDimension(dimensions.getDimension("Y", stage.getName()));
    schema.appendDimension(dimensions.getDimension("Z", stage.getName()));

    schema.appendDimension(dimensions.getDimension("Intensity", stage.getName()));
    schema.appendDimension(dimensions.getDimension("ReturnNumber", stage.getName())); // 3 bits only
    schema.appendDimension(dimensions.getDimension("NumberOfReturns", stage.getName())); // 3 bits only
    schema.appendDimension(dimensions.getDimension("ScanDirectionFlag", stage.getName()));  // 1 bit only
    schema.appendDimension(dimensions.getDimension("EdgeOfFlightLine", stage.getName())); // 1 bit only

    schema.appendDimension(dimensions.getDimension("Classification", stage.getName()));
    schema.appendDimension(dimensions.getDimension("ScanAngleRank", stage.getName()));

    schema.appendDimension(dimensions.getDimension("UserData", stage.getName()));
    schema.appendDimension(dimensions.getDimension("PointSourceId", stage.getName()));

    if (hasTime(format))
    {
        schema.appendDimension(dimensions.getDimension("Time", stage.getName()));
    }

    if (hasColor(format))
    {
        schema.appendDimension(dimensions.getDimension("Red", stage.getName()));
        schema.appendDimension(dimensions.getDimension("Green", stage.getName()));
        schema.appendDimension(dimensions.getDimension("Blue", stage.getName()));
    }

    // if (hasWave(format))
    // {
    //
    //     schema.appendDimension(Dimension(DimensionId::Las_WavePacketDescriptorIndex));
    //     schema.appendDimension(Dimension(DimensionId::Las_WaveformDataOffset));
    //     schema.appendDimension(Dimension(DimensionId::Las_ReturnPointWaveformLocation));
    //     schema.appendDimension(Dimension(DimensionId::Las_WaveformXt));
    //     schema.appendDimension(Dimension(DimensionId::Las_WaveformYt));
    //     schema.appendDimension(Dimension(DimensionId::Las_WaveformZt));
    // }

    return;
}
Example #8
0
const timeTuple& TimeManager::getTimeTuple(guidType timeGuid) {
    assert(hasTime(timeGuid) || "given timeGuid doesn't exist");

    //check if it's within the active time container
    for (auto& timeTuple : activeTimeContainer) {
	if (timeTuple.second == timeGuid) {
	    return timeTuple;
	}
    }

    //check if it's within the active time container
    for (auto& timeTuple : inActiveTimeContainer) {
	if (timeTuple.second == timeGuid) {
	    return timeTuple;
	}
    }

    return TimeManager::nullTime;
}
Example #9
0
void TimeManager::extendTime(guidType timeGuid, timeType duration) {
    assert(hasTime(timeGuid) || "timeTuple doesn't exist");

    //check if it's within the active time container
    for (auto timeTuple : activeTimeContainer) {
	if (timeTuple.second == timeGuid) {
	    timeTuple.first += duration;
	    inActiveTimeContainer.insert(timeTuple);
	    return;
	}
    }

    //check if it's within the inactive time container
    for (auto timeTuple : inActiveTimeContainer) {
	if (timeTuple.second == timeGuid) {
	    //grab the current time
	    timeType currentTime = static_cast<timeType>(SDL_GetTicks());
	    
	    timeTuple.first += duration;

	    //check to see if the new timestamp is even older after
	    //it's been extended
	    if (timeTuple.first < currentTime) {
		return;
	    }

	    //move it into the active container
	    activeTimeContainer.insert(timeTuple);

	    //remove it from the inactivecontainer
	    inActiveTimeContainer.erase(timeTuple);

	    return;
	}
    }
    assert(false || "Given Guid was manipulated");
}
Example #10
0
	int getTime(const Lit& lit){
		if(!hasTime(lit)){
			return newesttimepoint+1;
		}
		return var2time[(uint)var(lit)];
	}
Example #11
0
FileLog::EErrCode FileLog::_writeLog(ELogLevel level, time_t t, const char *time, const char *msg)
{
    static const size_t FILE_SIZE = 5*1024*1024;
    static const char *LOG_LEVEL[] = {
        0,
        "[Debug]",     // Debug
        "[Info]",      // Info
        0,
        "[Warn]",      // Warning
        0,0,0,
        "[Error]",     // Error
        0,0,0,0,0,0,0,
        "[Emphasis]",  // Emphasis
    };

    EErrCode rv = ErrCode_Unknown;
    int n;
    unsigned i;
    int logfd = fileno(mLogFile);

    if (logfd < 0)
    {
        return ErrCode_Unknown;
    }

    // 文件过大则需要转储
    struct stat st;
    if (fstat(logfd, &st) != 0)
    {
        goto end;
    }

    if ((size_t)st.st_size >= FILE_SIZE)
    {
        rv = ErrCode_CurFileFull;
        goto end;
    }

    // 写日志
    i = (unsigned)level;
    if (i < sizeof(LOG_LEVEL) / sizeof(LOG_LEVEL[0]) && LOG_LEVEL[i])
    {
        if (time && hasTime())
            n = fprintf(mLogFile, "%s%s%s\n", time, LOG_LEVEL[i], msg);
        else
            n = fprintf(mLogFile, "%s%s\n", msg, LOG_LEVEL[i]);
    }
    else
    {
        return ErrCode_ArgError;
    }

    if (n < 0)
    {
        return ErrCode_WriteFail;
    }
    if (fflush(mLogFile))
    {
        return ErrCode_CurFileFull;
    }

    rv = ErrCode_Success;

end:
    return rv;
}