uint32
UserRight::printValue( char* target, 
                       UserConstants::UserRightField field ) const
{
   switch ( field ) {
      case UserConstants::USER_RIGHT_ID :
      case UserConstants::USER_RIGHT_USERUIN :
         mc2log << error << "UserRight::printValue asked to print "
                << "ID or userUIN, not supported." << endl;
         MC2_ASSERT( false );
         break;
      case UserConstants::USER_RIGHT_ADD_TIME :
         sprintf( target, "%u", getAddTime() );
         break;
      case UserConstants::USER_RIGHT_TYPE :
         // Needs to be signed for MySQL to keep all bits.
         sprintf( target, "%lld",
                  static_cast<int64> ( getUserRightType().getAsInt() ) );
         break;
      case UserConstants::USER_RIGHT_REGION_ID :
         sprintf( target, "%u", getRegionID() );
         break;
      case UserConstants::USER_RIGHT_START_TIME :
         sprintf( target, "%u", getStartTime() );
         break;
      case UserConstants::USER_RIGHT_END_TIME :
         sprintf( target, "%u", getEndTime() );
         break;
      case UserConstants::USER_RIGHT_DELETED :
         sprintf( target, "%hu", isDeleted() );
         break;
      case UserConstants::USER_RIGHT_ORIGIN :
         strcat( target, "'" );
         sqlString( target + 1, getOrigin() );
         strcat( target, "'" );
         break;

      default:
         mc2log << error << "UserRight::printValue unknown " 
                << "fieldType: " << (int)field << endl;
         break;
   }

   return strlen( target );
}
示例#2
0
bool Condition::executeCondition(Creature* creature, const int32_t& interval)
{
	if (interval > 0)
	{
		bool bRemove = false;
		creature->onTickCondition(getType(), interval, bRemove);
	}

	if (ticks != -1)
	{
		int32_t newTicks = std::max(((int32_t)0), ((int32_t)getTicks() - interval));
		//Not using set ticks here since it would reset endTime
		ticks = newTicks;
		return (getEndTime() >= OTSYS_TIME());
	}

	return true;
}
示例#3
0
bool Condition::updateCondition(const Condition* addCondition)
{
	if (conditionType != addCondition->getType())
	{
		return false;
	}

	if (getTicks() == -1 && addCondition->getTicks() > 0)
	{
		return false;
	}

	if (addCondition->getTicks() >= 0 && getEndTime() > (OTSYS_TIME() + addCondition->getTicks()))
	{
		return false;
	}

	return true;
}
示例#4
0
void
Programme::getData(uint8_t &f0, uint8_t &f1, uint8_t &f2, uint8_t &f3, uint8_t &f4)
{
	
	if (isWeekday()) {
		f0 = 0xFF;
		f2 = getWeekdays();
	} else {
		f0 = getStartDayNumber();
		f2 = getEndDayNumber();
	}
	
	// Start and end times
	f1 = getStartTime();
	f3 = getEndTime();
	
	// Temperature
	f4 = getTemperature();
}
示例#5
0
void Scheduler::scheduleOneOffInFreeSpace(std::shared_ptr<std::vector<std::shared_ptr<Event>>> & scheduledEvents, const std::shared_ptr<const Task> & currentTask)
{
    unsigned int remainingDuration = currentTask->getDuration();
    unsigned int nextStartTime = currentTask->getEarliestStartTime();
    
    while(remainingDuration > 0)
    {
        auto newEvent = std::make_shared<Event>();
        unsigned int freeStartTime = 0;
        unsigned int freeDuration = 0;
        
        newEvent->setParent(currentTask);
        
        auto spaceIsAvailable = findFreeSpaceBetween(
                                                     nextStartTime,
                                                     currentTask->getLatestEndTime(),
                                                     freeStartTime,freeDuration);
        
        if(!spaceIsAvailable)
        {
            freeDuration = remainingDuration;
        }
        
        if(freeDuration > remainingDuration)
        {
            newEvent->setDuration(remainingDuration);
        }
        else
        {
            newEvent->setDuration(freeDuration);
        }
        
        newEvent->setStartTime(freeStartTime);
        
        scheduledEvents->push_back(newEvent);
        
        remainingDuration -= newEvent->getDuration();
        nextStartTime = newEvent->getEndTime();
    }
    
}
示例#6
0
bool Interval::getRealStartEndTime(time_t *t1, time_t *t2)
{
    bool bRet = false;
    Sequence *seq = new Sequence(*this, this->getSequenceName());
    
    if(seq) {
        if (seq->next() && seq->getType().compare("video") == 0) {
            time_t start = seq->getTimestamp("vid_time");
            float fps = seq->getFloat("vid_fps");
            
            if (start && fps) {
                *t1 = start + (time_t)(getStartTime() / fps);
                *t2 = start + (time_t) (getEndTime() / fps);
                bRet = true;
            }
        } 
        delete seq;
    }
    
    return bRet;
}
示例#7
0
void TraceAnalyzer::createTimeFilter(const vtl::Time &low,
				     const vtl::Time &high,
				     bool orlogic)
{
	vtl::Time start = getStartTime();
	vtl::Time end = getEndTime();

	if (low < start && high > end)
		return;

	if (orlogic) {
		OR_filterTimeLow = low;
		OR_filterTimeHigh = high;
		OR_filterState.enable(FilterState::FILTER_TIME);
	} else {
		filterTimeLow = low;
		filterTimeHigh = high;
		filterState.enable(FilterState::FILTER_TIME);
	}
	/* No need to process filters if we only have OR-filters */
	if (filterState.isEnabled())
		processAllFilters();
}
示例#8
0
AnimationClip* AnimationClip::clone(Animation* animation) const
{
    // Don't clone the elapsed time, listeners or crossfade information.
    AnimationClip* newClip = new AnimationClip(getId(), animation, getStartTime(), getEndTime());
    newClip->setSpeed(getSpeed());
    newClip->setRepeatCount(getRepeatCount());
    newClip->setBlendWeight(getBlendWeight());
    
    size_t size = _values.size();
    newClip->_values.resize(size, NULL);
    for (size_t i = 0; i < size; ++i)
    {
        if (newClip->_values[i] == NULL)
        {
            newClip->_values[i] = new AnimationValue(*_values[i]);
        }
        else
        {
            *newClip->_values[i] = *_values[i];
        }
    }
    return newClip;
}
示例#9
0
void CompartmentReportHDF5::_createDataAttributes( H5::DataSet& dataset )
{
    const int rank = 0;
    const double startTime = getStartTime();
    const double endTime = getEndTime();
    const double timestep = getTimestep();

    H5::Attribute rankAttr = dataset.createAttribute( dataAttributes[0],
                                     H5::PredType::NATIVE_INT, H5S_SCALAR );
    H5::Attribute tstartAttr = dataset.createAttribute( dataAttributes[1],
                                  H5::PredType::NATIVE_DOUBLE, H5S_SCALAR );
    H5::Attribute tstopAttr = dataset.createAttribute( dataAttributes[2],
                                  H5::PredType::NATIVE_DOUBLE, H5S_SCALAR );
    H5::Attribute dtAttr = dataset.createAttribute( dataAttributes[3],
                                  H5::PredType::NATIVE_DOUBLE, H5S_SCALAR );

    rankAttr.write( H5::PredType::NATIVE_INT, &rank );
    tstartAttr.write( H5::PredType::NATIVE_DOUBLE, &startTime );
    tstopAttr.write( H5::PredType::NATIVE_DOUBLE, &endTime );
    dtAttr.write( H5::PredType::NATIVE_DOUBLE, &timestep );
    detail::addStringAttribute( dataset, dataAttributes[4], _dunit );
    detail::addStringAttribute( dataset, dataAttributes[5], _tunit );
}
示例#10
0
 void
 CreatureManager::MakePointCache(const std::string& animation_name_in)
 {
     float store_run_time = getRunTime();
     auto cur_animation = animations[animation_name_in];
     if(cur_animation->hasCachePts())
     {
         // cache already generated, just exit
         return;
     }
     
     std::vector<glm::float32 *>& cache_pts_list = cur_animation->getCachePts();
     
     for(int i = (int)cur_animation->getStartTime(); i <= (int)cur_animation->getEndTime(); i++)
     {
         setRunTime((float)i);
         auto new_pts = new glm::float32[target_creature->GetTotalNumPoints() * 3];
         PoseCreature(animation_name_in, new_pts, getRunTime());
         
         cache_pts_list.push_back(new_pts);
     }
     
     setRunTime(store_run_time);
 }
示例#11
0
	/// \brief get interpolated value at time t
	///
	T_value getValue(T_time t) const {
		assert(t >= getStartTime());
		assert(t < getEndTime());

		// find i
		int i=2;
		while (this->_times[i] <= t) i++;

		// compute points and tangents
		const T_time G = (1+sqrt(5))/2;
		T_value P1 = this->_values[i-1];
		T_value P4 = this->_values[i];
		T_value R1 = G / (this->_times[i]-this->_times[i-2])*(this->_values[i]-this->_values[i-2]);
		T_value R4 = G / (this->_times[i+1]-this->_times[i-1])*(this->_values[i+1]-this->_values[i-1]);

		// compute hermite interpolation
		T_time tu = (t-this->_times[i-1]) / (this->_times[i]-this->_times[i-1]);
		T_time tu2 = tu*tu;
		T_time tu3 = tu2*tu;
		return (2*tu3 - 3*tu2 + 1) * P1
				+ (-2*tu3 + 3*tu2) * P4
				+ (tu3 - 2*tu2 + tu) * R1
				+ (tu3 - tu2) * R4;
	}
void 
UCreatureMeshComponent::RunCollectionTick(float DeltaTime)
{
	UpdateCoreValues();

	if (bHiddenInGame)
	{
		return;
	}

	if (active_collection_clip == nullptr)
	{
		return;
	}

	float true_delta_time = DeltaTime * animation_speed;
	auto cur_data = GetCollectionDataFromClip(active_collection_clip);
	if (cur_data == nullptr)
	{
		return;
	}

	if (cur_data->animation_speed > 0)
	{
		true_delta_time = DeltaTime * cur_data->animation_speed;
	}

	if (active_collection_play == false)
	{
		true_delta_time = 0;
	}

	TArray<FProceduralMeshTriangle>& write_triangles = cur_data->ProceduralMeshTris;
	auto& cur_core = cur_data->creature_core;
	if (cur_core.GetCreatureManager() == nullptr)
	{
		return;
	}

	cur_core.should_play = true;
	bool can_tick = cur_core.RunTick(true_delta_time);

	if (can_tick) {
		// Events
		bool announce_start = cur_core.GetAndClearShouldAnimStart();
		bool announce_end = cur_core.GetAndClearShouldAnimEnd();

		float cur_runtime = (cur_core.GetCreatureManager()->getActualRunTime());

		bool is_collection_start = (active_collection_clip->active_index == 0) && announce_start;
		bool is_collection_end = (active_collection_clip->active_index == active_collection_clip->sequence_clips.Num() - 1) && announce_end;

		if (is_collection_start)
		{
			CreatureAnimationStartEvent.Broadcast(cur_runtime);
		}

		if (is_collection_end)
		{
			CreatureAnimationEndEvent.Broadcast(cur_runtime);
		}

		// Process Collection Clip
		auto cur_manager = cur_core.GetCreatureManager();
		auto& all_animations = cur_manager->GetAllAnimations();
		auto& cur_token = active_collection_clip->sequence_clips[active_collection_clip->active_index];
		std::string anim_string = ConvertToString(cur_token.animation_name);
		if (all_animations.count(anim_string) == 0)
		{
			return;
		}

		auto clip_animation = all_animations.at(anim_string).get();
		float next_time = cur_runtime + true_delta_time;

		if (next_time >= clip_animation->getEndTime())
		{
			// At the end of current clip, see if we should switch to the next clip
			int next_active_index = active_collection_clip->active_index + 1;
			int seq_num = active_collection_clip->sequence_clips.Num();
			bool do_switch = false;
			if (next_active_index >= seq_num)
			{
				if (active_collection_loop)
				{
					active_collection_clip->active_index = 0;
					do_switch = true;
				}
			}
			else {
				active_collection_clip->active_index++;
				do_switch = true;
			}

			if (do_switch)
			{
				SetActiveCollectionAnimation(active_collection_clip);
			}
		}

		DoCreatureMeshUpdate(GetCollectionDataIndexFromClip(active_collection_clip));
	}
}
示例#13
0
int GatherTask::getEndTime(Unit unit) const
{
	return getEndTime();
}
示例#14
0
int TrainTask::getEndTime(Unit unit) const
{
	return getEndTime();
}
示例#15
0
void printOutput(HumdrumFile& hfile) {
   Array<double> tempo;
   hfile.analyzeTempoMarkings(tempo, tdefault);

   double currentmillisecond = 0.0;
   double lastduration = 0.0;

   double linestarttime = 0.0;
   double lineendtime = 0.0;

   int founddata = 0;

   int metlev;
   int i, j, k;
   char buffer1[1024] = {0};
   char buffer2[1024] = {0};
   double duration;
   for (i=0; i<hfile.getNumLines(); i++) {
      currentmillisecond = currentmillisecond + 
            lastduration * 60000.0 / tempo[i];
      lastduration = hfile[i].getDuration();

      if (hfile[i].getType() == E_humrec_global_comment) {
         cout << "%% " << &(hfile[i].getLine()[3]) << endl;
      }

      if (hfile[i].getType() == E_humrec_bibliography) {
         cout << "%%%" << &(hfile[i].getLine()[3]) << endl;
      }


      if (hfile[i].getType() != E_humrec_data) {
         continue;
      }

      if (debugQ) {
         cout << "RECORD: " << hfile[i] << endl;
      }

      if (founddata == 0) {
         founddata = 1;

         comment(cout, 2, humdrumQ);
         cout << " Data column information:\n";
         comment(cout, 3, humdrumQ);
         cout << "col01: abstime\t" << 
                 "(average absolute time in milliseconds of human "
              << "beats)\n";
         comment(cout, 3, humdrumQ);
         cout << "col02: duration\t" <<
                 "(expected duration in ms based "
              << "on score duration)\n";
         comment(cout, 3, humdrumQ);
         cout << "col03: note\t\t" << 
                 "(MIDI note number of pitch)\n";
         comment(cout, 3, humdrumQ);
         cout << "col04: metlev\t" << 
                 "(metric level: 1 = downbeat; "
              <<  "0 = beat; -1 = offbeat)\n";
         comment(cout, 3, humdrumQ);
         cout << "col05: measure\t" <<
                  "(measure number in which note occurs)\n";
         comment(cout, 3, humdrumQ);
         cout << "col06: absbeat\t" <<
                 "(absolute beat from starting beat at 0)\n";
         comment(cout, 3, humdrumQ);
         cout << "col07: trackno\t" << 
                 "(hand which plays the note: 1 = left; 2=right)\n";
	 if (!auxdataQ) {
            comment(cout, 3, humdrumQ);
            cout << "col08: mintime\t" << 
                    "(minimum absolute time of human beat for this note)\n";
            comment(cout, 3, humdrumQ);
            cout << "col09: maxtime\t" << 
                    "(maximum absolute time of human beat for this note)\n";
            comment(cout, 3, humdrumQ);
            cout << "col10: sd\t\t" << 
                    "(standard deviation of human beat time in ms.)\n";
	 } else {
            //comment(cout, 3, humdrumQ);
            //cout << "col08: paccid\t" <<
	    //	    "(printed accidental 0=none, -1=flat, +1=sharp, 10=nat)\n";
            comment(cout, 3, humdrumQ);
            cout << "col08: saccid\t" <<
		    "(sounding accidental 0=natural, -1=flat, +1=sharp)\n";
         }
		   
         if (humdrumQ) {
            cout << "**start\t**dur\t**key\t**metr\t**meas\t**absb\t**track\t**saccid\n";
         }
      }
	        

      linestarttime = -1.0;
      // find current time value and save 
      for (j=0; j<hfile[i].getFieldCount(); j++) {
         if (strcmp(hfile[i].getExInterp(j), "**time") == 0) {
            sscanf(hfile[i][j], "%lf", &linestarttime);
            break;
         }
      }

      for (j=0; j<hfile[i].getFieldCount(); j++) {
         if (hfile[i].getExInterpNum(j) != E_KERN_EXINT) {
            continue;
         }

         for (k=0; k<hfile[i].getTokenCount(j); k++) {
            if (strcmp(hfile[i][j], ".") == 0) {
               continue;
            }
            hfile[i].getToken(buffer1, j, k);
            if (strchr(buffer1, '_') != NULL) {
               // ignore notes which are tied
               continue;
            }
            if (strchr(buffer1, ']') != NULL) {
               // ignore notes which are tied
               continue;
            }

            preparePitch(buffer2, buffer1);
            duration = hfile.getTiedDuration(i, j, k);
            lineendtime = getEndTime(hfile, i, duration);

            int note = Convert::kernToMidiNoteNumber(buffer2);
            if (classQ) {
               note = note % 12;
            }
            if (note < 0) {
               // don't display rests.
               continue;
            }
            if (note < 0 || note > 127) {
               cerr << "Error reading MIDI pitch number from string: " 
                    << buffer2 << endl;
               exit(1);
            }

            //cout << "Note\t";
            // cout << hfile.getAbsBeat(i) << "\t";
            // cout << (int)(currentmillisecond+0.5) << "\t";
            cout << linestarttime << "\t";

            if (debugQ && (lineendtime - linestarttime < 0)) {
               cerr << "Error duration of note on line: " << hfile[i] << endl;
               cerr << "Starttime: " << linestarttime << endl;
               cerr << "Endtime:   " << lineendtime << endl;
               cerr << "Line Index:     " << i << endl;
               exit(1);
            } 
            if (lineendtime != -1) {
               cout << lineendtime - linestarttime << "\t";
            } else {
               cout << (int)(getTimeToEnd(hfile, linestarttime, i) + 0.5) 
                    << "\t";
            }

            cout << note;

            cout << "\t";
            
            metlev = getMetricLevel(hfile, i);
            cout << metlev;

            cout << "\t" << getMeasureNum(hfile, i);

            cout << "\t" << hfile[i].getAbsBeat();

            // you must make sure that the spine order is
            // correct or this data will be bad
            cout << "\t" << hfile[i].getPrimaryTrack(j)-1;
   
            cout << "\t"; 
	    printSaccid(cout, buffer2);
 
            cout << "\n";
         }
      }
   }

   if (humdrumQ) {
      cout << "*-\t*-\t*-\t*-\t*-\t*-\t*-\t*-\n";
   }
}
void CollapseRestsCommand::modifySegment()
{
    SegmentNotationHelper helper(getSegment());
    helper.collapseRestsAggressively(getStartTime(), getEndTime());
}
示例#17
0
int IdleTask::getEndTime(Unit unit) const
{
	return getEndTime();
}
void OsuManiaRenderer::RenderTimings(Window& _win)
{
	_win.font->draw(core::stringw(getEndTime()), core::rect<s32>(absXpos + width, absYpos, 100, 10), video::SColor(255, 255, 255, 255));
	_win.font->draw(core::stringw(getStartTime()), core::rect<s32>(absXpos + width, absYpos + height, 100, 10), video::SColor(255, 255, 255, 255));
}
GLuint CC3NodeAnimationSegment::getEndFrameIndex()
{
	return m_pBaseAnimation->getFrameIndexAt( getEndTime() ); 
}
int MineBlockingMineralTask::getEndTime(Unit unit) const
{
	return getEndTime();
}
示例#21
0
float peanoclaw::native::scenarios::CalmOcean::endSimulation() {
  return (float)getEndTime();
}
示例#22
0
bool Scheduler::findFreeSpaceBetween(unsigned int startTime, unsigned int endTime, unsigned int & freeStartTime, unsigned int & freeDuration)
{
    bool found = true;
    auto newEvent = std::make_shared<Event>(startTime,(endTime - startTime));
    
    if(scheduledEvents.size() == 0)
    {
        freeDuration = endTime - startTime;
        freeStartTime = startTime;
    }
    else
    {
        auto lowerBound =
            std::lower_bound(scheduledEvents.begin(),scheduledEvents.end(),newEvent,compareEvents);
        
        freeDuration = 0;
        while(freeDuration == 0)
        {
            if(lowerBound == scheduledEvents.begin())
            {
                auto closestEvent = *lowerBound;
                
                if(startTime < closestEvent->getStartTime())
                {
                    freeDuration = closestEvent->getStartTime() - startTime;
                    freeStartTime = closestEvent->getStartTime() - freeDuration;
                }
            }
            else if(lowerBound == scheduledEvents.end())
            {
                lowerBound--;
                auto closestEvent = *lowerBound;
                
                if((closestEvent->getEndTime() < endTime) && (closestEvent->getEndTime() >= startTime))
                {
                    freeDuration = endTime - closestEvent->getEndTime();
                    freeStartTime = closestEvent->getEndTime();
                }
                else
                {
                    if(closestEvent->getEndTime() >= startTime)
                    {
                        freeStartTime = closestEvent->getEndTime();
                    }
                    else
                    {
                        freeStartTime = startTime;                        
                    }
                    
                    found = false;
                    break;
                }
            }
            else
            {
                auto closestEvent = *lowerBound;
                auto nextClosestEvent = *(++lowerBound);
                
                freeDuration = closestEvent->getEndTime() - nextClosestEvent->getStartTime();
                freeStartTime = closestEvent->getEndTime();
            }
            
            lowerBound++;
        }
        
    }
    
    return found;
}
示例#23
0
int TechTask::getEndTime(Unit unit) const
{
	return getEndTime();
}
示例#24
0
size_t CompartmentReportCommon::getFrameCount() const
{
    if (getStartTime() < getEndTime())
        return _getFrameNumber(getEndTime()) + 1;
    return 0;
}