예제 #1
0
void Clock::AdvanceTime(float deltaSecs)
{
	deltaSecs = min(m_maximumDelta, deltaSecs);
	deltaSecs *= m_timeScale;
	if (m_paused) {
		deltaSecs = 0.f;
	}

	m_currentTime += deltaSecs;
	m_deltaSeconds = deltaSecs;

	for (auto it = m_children.begin(); it != m_children.end(); ++it) {
		Clock* childClock = *it;
		childClock->AdvanceTime(deltaSecs);
	}

	for (auto it = m_alarms.begin(); it != m_alarms.end();) {
		Alarm* alarm = it->second;
		alarm->elapsedTime += deltaSecs;

		if (alarm->elapsedTime >= alarm->timeToFire) {
			it = m_alarms.erase(it);
			alarm->onAlarmFire(alarm->name, alarm->alarmFunctionData);
		}
		else {
			++it;
		}
	}
}
예제 #2
0
void DevicePluginDateTime::deviceRemoved(Device *device)
{
    // check if we still need the timer
    if (myDevices().count() == 0) {
        m_timer->stop();
    }

    // date
    if (device->deviceClassId() == todayDeviceClassId) {
        m_todayDevice = 0;
    }

    // alarm
    if (device->deviceClassId() == alarmDeviceClassId) {
        Alarm *alarm = m_alarms.take(device);
        alarm->deleteLater();
    }

    // countdown
    if (device->deviceClassId() == countdownDeviceClassId) {
        Countdown *countdown = m_countdowns.take(device);
        countdown->deleteLater();
    }

    startMonitoringAutoDevices();
}
예제 #3
0
파일: main.cpp 프로젝트: thddaniel/QT
int main(int argc,char *argv[])
{
	QApplication app(argc,argv);
	Alarm alarm;
	alarm.show();
	return app.exec();
};
예제 #4
0
void Submarine::tick(const float dt) {
	Object::tick(dt);

	if (!playing_sound("submarine")) {
		play_sound("submarine", true);
	}

	if (get_state().empty()) {
		_wakeup.set(mrt::random(5) + 5);
		play("hold", true);
	}
	if (_wakeup.tick(dt)) {
		//LOG_DEBUG(("waking up..."));
		spawnBallistic();
		_wakeup.set(3600);
		
		cancel_all();
		play("fade-in", false);
		int n = mrt::random(3) + 3;
		for(int i = 0; i < n; ++i) {
			play("main", false);
		}

		play("fade-out", false);
	}
}
예제 #5
0
void Clock::AdvanceTime(double deltaTime)
{
	if(m_pause)
		return;

	if(deltaTime > m_maxDeltaTimeStep)
		deltaTime = m_maxDeltaTimeStep;

	std::vector<Clock*>::iterator clock_it = m_childClocks.begin();
	for( ; clock_it != m_childClocks.end(); ++clock_it)
	{
		Clock* currentClock = *clock_it;
		currentClock->AdvanceTime(deltaTime);
	}

	std::vector<Alarm*>::iterator alarm_it = m_alarms.begin();
	while(alarm_it != m_alarms.end())
	{
		Alarm* currentAlarm = *alarm_it;
		currentAlarm->AdvanceTime(deltaTime);
		if(currentAlarm->m_destroy)
		{
			alarm_it = m_alarms.erase(alarm_it);
			delete currentAlarm;
			currentAlarm = nullptr;
		}
		else
			++alarm_it;
	}

	m_currentTimeSeconds += deltaTime * m_timeScale;
	m_lastTimeStep = deltaTime;
}
예제 #6
0
파일: file.cpp 프로젝트: joeljk13/WinAlarm
int
read_file(std::vector<Alarm> &alarms)
{
	std::vector<std::string> lines;

	if (read_lines(lines) != 0) {
		return -1;
	}

	for (const std::string &str : lines) {
		Alarm alarm;

		if (alarm.read_file_str(str.c_str()) != 0) {
			return -1;
		}

		try {
			alarms.push_back(alarm);
		}
		catch (...) {
			fputs("Error: unable to allocate memory\n", stderr);
			return -1;
		}
	}

	return 0;
}
예제 #7
0
void PVAlarm::get(Alarm & alarm) const
{
    if(pvSeverity.get()==NULL) {
        throw std::logic_error(notAttached);
    }
    alarm.setSeverity(AlarmSeverityFunc::getSeverity(pvSeverity->get()));
    alarm.setStatus(AlarmStatusFunc::getStatus(pvStatus->get()));
    alarm.setMessage(pvMessage->get());
}
예제 #8
0
파일: Alarm.cpp 프로젝트: epatel/Cosa
void
Alarm::enable()
{
  Alarm* alarm = (Alarm*) s_queue.get_succ(); 
  while (alarm != (Alarm*) &s_queue) {
    int32_t diff = m_when - alarm->m_when;
    if (diff <= 0) break;
    alarm = (Alarm*) alarm->get_succ();
  }
  alarm->attach(this);
}
예제 #9
0
void ConfigurationDialog::UpdateItem(int index)
{
    Alarm *alarm = Alarm::s_Alarms[index];

    m_lAlarms->SetItem(index, ALARM_TYPE, alarm->Type());
    m_lAlarms->SetColumnWidth(ALARM_TYPE, wxLIST_AUTOSIZE);
    m_lAlarms->SetItem(index, ALARM_OPTIONS, alarm->Options());
    m_lAlarms->SetColumnWidth(ALARM_OPTIONS, wxLIST_AUTOSIZE);
    m_lAlarms->SetItem(index, ALARM_ACTION, alarm->Action());
    m_lAlarms->SetColumnWidth(ALARM_ACTION, wxLIST_AUTOSIZE);
}
예제 #10
0
void WatchdogDialog::UpdateStatus(int index)
{
    Alarm *alarm = Alarm::s_Alarms[index];
    m_lStatus->SetItemImage(index, alarm->m_bEnabled ? 1 : 0);

//    m_lAlarms->SetItem(index, ALARM_ENABLED, alarm->m_bEnabled ? _T("X") : _T(""));
    m_lStatus->SetItem(index, ALARM_TYPE, alarm->Type());
    m_lStatus->SetItem(index, ALARM_STATUS, alarm->GetStatus());
    m_lStatus->SetItemTextColour(index, alarm->m_bFired ? *wxRED: *wxBLACK);
    m_lStatus->SetColumnWidth(ALARM_STATUS, wxLIST_AUTOSIZE);
}
예제 #11
0
bool PVAlarm::set(Alarm const & alarm)
{
    if(pvSeverity.get()==NULL) {
        throw std::logic_error(notAttached);
    }
    if(pvSeverity->isImmutable() || pvMessage->isImmutable()) return false;
    pvSeverity->put(alarm.getSeverity());
    pvStatus->put(alarm.getStatus());
    pvMessage->put(alarm.getMessage());
    return true;
}
예제 #12
0
파일: Alarm.cpp 프로젝트: rrobinet/Cosa
void
Alarm::enable()
{
  // Enqueue the alarm in the schedule queue
  Alarm* alarm = (Alarm*) s_queue.get_succ();
  while (alarm != (Alarm*) &s_queue) {
    int32_t diff = m_when - alarm->m_when;
    if (UNLIKELY(diff <= 0)) break;
    alarm = (Alarm*) alarm->get_succ();
  }
  alarm->attach(this);
}
예제 #13
0
파일: Alarm.cpp 프로젝트: epatel/Cosa
void
Alarm::tick()
{
  Alarm* alarm;
  s_ticks += 1;
  while ((alarm = (Alarm*) s_queue.get_succ()) != (Alarm*) &s_queue) {
    int32_t diff = alarm->m_when - s_ticks;
    if (diff > 0) break;
    alarm->detach();
    alarm->run();
    if (alarm->m_period != 0) {
      alarm->m_when += alarm->m_period;
      alarm->enable();
    }
  }
}
예제 #14
0
파일: barrack.cpp 프로젝트: sorokin/btanks
void Barrack::tick(const float dt) {
	DestructableObject::tick(dt);

	if (!_broken && _spawn.tick(dt)) {
		if (hp == max_hp) { //nothing happens
			int tr;
			Config->get("objects." + registered_name + ".targeting-range", tr, 500);

			v2<float> pos, vel;
			if (!get_nearest(ai::Targets->infantry, tr, pos, vel, false))
				return; //skip spawning
		}
		
		int max_c;
		Config->get("objects." + registered_name + ".maximum-children", max_c, 5);
		int n = get_children(std::string());
		if (n < max_c) {
			v2<float>dpos;
			dpos.y = size.y / 2 + 16; //fixme: use debiloids size here.
			
			Object * o = spawn(_object, _animation, dpos);
			o->copy_special_owners(this);
			play_now("spawn");
		}
	}
}
예제 #15
0
// It is safe to call this function again from inside a callback function
// that it called. It should not be called from multiple threads at once.
void
Alarm_process(void) {
    AlarmTime now;

    assert(alarmHeap != NULL);

    now = AlarmTime_nowMS();
    while (Heap_hasMore(alarmHeap)) {
        Alarm *alarm = (Alarm *) Heap_first(alarmHeap);

        if (now < alarm->time)
            break;

        Heap_pop(alarmHeap);
        alarm->callback(alarm->arg);
        Alarm_free(alarm);
    }
}
void KCalResourceSlox::parseIncidenceAttribute( const QDomElement &e,
                                                Incidence *incidence )
{
  QString tag = e.tagName();
  QString text = decodeText( e.text() );
  if ( text.isEmpty() ) return;

  if ( tag == fieldName( IncidenceTitle ) ) {
    incidence->setSummary( text );
  } else if ( e.tagName() == fieldName( Description ) ) {
    incidence->setDescription( text );
  } else if ( tag == fieldName( Reminder ) ) {
    int minutes = text.toInt();
    if ( minutes != 0 ) {
      Alarm::List alarms = incidence->alarms();
      Alarm *alarm;
      if ( alarms.isEmpty() ) alarm = incidence->newAlarm();
      else alarm = alarms.first();
      if ( alarm->type() == Alarm::Invalid ) {
        alarm->setType( Alarm::Display );
      }
      Duration d( minutes * -60 );
      alarm->setStartOffset( d );
      alarm->setEnabled( true );
    } else {
      // 0 reminder -> disable alarm
      incidence->clearAlarms();
    }
  } else if ( tag == fieldName( CreatedBy ) ) {
    KABC::Addressee a;
    if ( mAccounts ) a = mAccounts->lookupUser( text );
    else kDebug() << "KCalResourceSlox: no accounts set";
    incidence->setOrganizer( Person( a.formattedName(), a.preferredEmail() ) );
  } else if ( tag == fieldName( Participants ) ) {
    parseMembersAttribute( e, incidence );
  } else if ( tag == "readrights" ) {
    parseReadRightsAttribute( e, incidence );
  } else if ( tag == fieldName( Categories ) ) {
    incidence->setCategories( text.split( QRegExp(",\\s*") ) );
  } else if ( tag == fieldName( LastModified ) && type() == "ox" ) {
    incidence->setCustomProperty( "SLOX", "LastModified", text );
  }
}
예제 #17
0
파일: Alarm.cpp 프로젝트: rrobinet/Cosa
void
Alarm::tick()
{
  Alarm* alarm;
  s_ticks += 1;

  // Check for alarms that should be run
  while ((alarm = (Alarm*) s_queue.get_succ()) != (Alarm*) &s_queue) {
    int32_t diff = alarm->m_when - s_ticks;
    if (UNLIKELY(diff > 0)) break;
    alarm->detach();
    alarm->run();
    // Check if the alarm should be rescheduled (periodic)
    if (alarm->m_period != 0) {
      alarm->m_when += alarm->m_period;
      alarm->enable();
    }
  }
}
예제 #18
0
QStringList KOAlarmClient::dumpAlarms()
{
  KDateTime start = KDateTime( QDateTime::currentDateTime().date(),
                               QTime( 0, 0 ), KDateTime::LocalZone );
  KDateTime end = start.addDays( 1 ).addSecs( -1 );

  QStringList lst;
  // Don't translate, this is for debugging purposes.
  lst << QString( "AlarmDeamon::dumpAlarms() from " ) + start.toString() + " to " +
         end.toString();

  QList<Alarm *> alarms = mCalendar->alarms( start, end );
  QList<Alarm *>::ConstIterator it;
  for ( it = alarms.constBegin(); it != alarms.constEnd(); ++it ) {
    Alarm *a = *it;
    lst << QString( "  " ) + a->parent()->summary() + " (" + a->time().toString() + ')';
  }

  return lst;
}
예제 #19
0
파일: cannon.cpp 프로젝트: sorokin/btanks
void Cannon::tick(const float dt) {
	Object::tick(dt);
	if (get_state() == "real-fire") {
		cancel();
		spawn("cannon-bullet", "cannon-bullet", v2<float>(), _direction);
	}
	
	bool can_fire = _fire.tick(dt);
	if (_state.fire && can_fire) {
		_fire.reset();
		
		if (get_state() == "hold") {
			cancel_all();
			play("fire", false);
			play("real-fire", true);
			play("after-fire", false);
			play("hold", true);
		}
	}
}
예제 #20
0
파일: alarm.C 프로젝트: debdungeon/qint
void Alarm::cancel_sig(unsigned seconds_left)
{
Alarm	*p;
Alarm	*alarm_chain=0;

	while ((p=first) != 0 && p->set_interval <= seconds_left)
			// Marginal case
	{
		p->Unlink();
		p->next=alarm_chain;
		alarm_chain=p;
	}

	for (p=first; p; p=p->next)
		p->set_interval -= seconds_left;

	while ((p=alarm_chain) != 0)
	{
		alarm_chain=p->next;
		p->handler();
	}
}
예제 #21
0
파일: cannon.cpp 프로젝트: sorokin/btanks
void Cannon::calculate(const float dt) {
	if (!_reaction.tick(dt))
		return;
	
	static float range = getWeaponRange("cannon-bullet");
	v2<float> pos, vel;
	if (get_nearest(_variants.has("trainophobic")? ai::Targets->infantry_and_train: ai::Targets->infantry, range, pos, vel, true)) {
		pos.normalize();
		set_direction(pos.get_direction(get_directions_number()) - 1);
		_direction = pos;
		_state.fire = true;
	} else _state.fire = false;
}
예제 #22
0
파일: bullet.cpp 프로젝트: sorokin/btanks
void Bullet::tick(const float dt) {
	Object::tick(dt);
	if (_type == "dispersion") {
		//LOG_DEBUG(("baaaaaaah!"));
		if (_clone.tick(dt)) {
			_clone.set(3600);
			//LOG_DEBUG(("%d clones...", get_id()));
			
			GET_CONFIG_VALUE("objects.dispersion-bullet.ttl-multiplier", float, ttl_m, 0.8);
			const int dirs = get_directions_number();
			int d = (get_direction() + 1) % dirs;
			v2<float> vel;
			vel.fromDirection(d, dirs);
			Object * b = spawn(registered_name + "(no-sound)", animation, v2<float>(), vel);
			b->ttl = ttl * ttl_m;
			
			d = (dirs + get_direction() - 1) % dirs;
			vel.fromDirection(d, dirs);
			b = spawn(registered_name + "(no-sound)", animation, v2<float>(), vel);
			b->ttl = ttl * ttl_m;
		}
	} else if (_type == "ricochet") {
예제 #23
0
void updateAlarm()
{
	time_t almTime = wkAlarm.getAlarmTime();
	int h = hour(almTime);
	int m = minute(almTime);

	digitValues[0] = h / 10;
	digitValues[1] = h % 10;
	digitValues[2] = m / 10;
	digitValues[3] = m % 10;

	for (int i = 0; i < N; i++)
		display.writeDigit(i, digitValues[i]);
}
예제 #24
0
void setRtcAlarm(byte hour, byte minute)
{	
	// copy time_t object, modify some fields, 
	// inherit month, day, dayOfWeek and Year.
	time_t justNow = now();
	tmElements_t alarmSetting;
	breakTime(justNow, alarmSetting);

	alarmSetting.Hour = hour;
	alarmSetting.Minute = minute;
	alarmSetting.Second = 0;
	wkAlarm.setAlarmTime(makeTime(alarmSetting));

	printAlarmStatus();
}
예제 #25
0
void printAlarmStatus()
{
	time_t almSet = wkAlarm.getAlarmTime();
	byte h, m, rtcOn;
	h = hour(almSet);
	m = minute(almSet);
	printDigits(h,' ');
	printDigits(m,':');
	rtcOn = isRtcAlarmOn();
	if (rtcOn)
		Serial.println(" -- ON");
	else
		Serial.println(" -- OFF");

}
예제 #26
0
void BDHServerController::addConfigurationAlarm(QXmlAttributes a)
{
    Alarm alarm;

    alarm.setIdAlarm(m_alarmCounter++);
    alarm.setAlarmType((quint8)a.value("type").toInt());
    alarm.setPriority((quint8)a.value("priority").toInt());
    alarm.setSeverity((quint8)a.value("severity").toInt());
    alarm.setDescription(a.value("description"));

    m_configuration.addAlarm(alarm);

//    qDebug() <<"Encontro una alarma!!!!\n";
}
예제 #27
0
void Helicopter::tick(const float dt) {
	Object::tick(dt);
	GET_CONFIG_VALUE("objects.helicopter-with-kamikazes.maximum-children", int, max_c, 10);
	if (_active && _spawn.tick(dt)) {
		if (get_children("kamikaze") >= max_c) 
			return;
		
		const Matrix<int> & matrix  = Map->get_impassability_matrix(0);

		v2<int> pos, pos2;
		get_center_position(pos); 
		v2<int> para_size = ResourceManager->getClass(_paratrooper)->size.convert<int>();
		pos -= para_size / 2;
		
		pos2 = pos;
		pos2 += para_size;
		pos2 -= 1;

		const v2<int> tile_size = Map->getTileSize();

		pos /= tile_size;
		pos2 /= tile_size;
		/*
		LOG_DEBUG(("%d %d", matrix.get(pos.y, pos.x), matrix.get(pos.y, pos2.x)));
		LOG_DEBUG(("%d %d", matrix.get(pos2.y, pos.x), matrix.get(pos2.y, pos2.x)));
		*/
		if (matrix.get(pos.y, pos.x) < 0 || matrix.get(pos.y, pos2.x) < 0 || 
			matrix.get(pos2.y, pos.x) < 0 || matrix.get(pos2.y, pos2.x) < 0) {
				LOG_DEBUG(("cannot drop paratrooper, sir!"));
			} else {
				int pt = mrt::random(6);
				//LOG_DEBUG(("ptype = %d", pt));
				std::string animation = (pt == 3)? "gay-paratrooper": "paratrooper";
					
				spawn(_paratrooper, animation);
			}
	} 
	if (!_active)
		_velocity.clear();
}
예제 #28
0
 void comeHome()
 {
         alarm.alarmOff();
         ac.acOn();
         tv.tvOn();
 }
예제 #29
0
 void goToWork()
 {
         ac.acOff();
         tv.tvOff();
         alarm.alarmOn();
 }
void test_ntscalarArray()
{
    testDiag("test_ntscalarArray");

    NTScalarArrayBuilderPtr builder = NTScalarArray::createBuilder();
    testOk(builder.get() != 0, "Got builder");

    NTScalarArrayPtr ntScalarArray = builder->
            value(pvInt)->
            addDescriptor()->
            addAlarm()->
            addTimeStamp()->
            addDisplay()->
            addControl()->
            create();
    testOk1(ntScalarArray.get() != 0);

    testOk1(ntScalarArray->getPVStructure().get() != 0);
    testOk1(ntScalarArray->getValue().get() != 0);
    testOk1(ntScalarArray->getDescriptor().get() != 0);
    testOk1(ntScalarArray->getAlarm().get() != 0);
    testOk1(ntScalarArray->getTimeStamp().get() != 0);
    testOk1(ntScalarArray->getDisplay().get() != 0);
    testOk1(ntScalarArray->getControl().get() != 0);

    //
    // example how to set values
    //
    PVIntArray::svector newValues;
    newValues.push_back(1);
    newValues.push_back(2);
    newValues.push_back(8);

    PVIntArrayPtr pvValueField = ntScalarArray->getValue<PVIntArray>();
    pvValueField->replace(freeze(newValues));

    //
    // example how to get values
    //
    PVIntArray::const_svector values(pvValueField->view());

    testOk1(values.size() == 3);
    testOk1(values[0] == 1);
    testOk1(values[1] == 2);
    testOk1(values[2] == 8);

    //
    // timeStamp ops
    //
    PVTimeStamp pvTimeStamp;
    if (ntScalarArray->attachTimeStamp(pvTimeStamp))
    {
        testPass("timeStamp attach");

        // example how to set current time
        TimeStamp ts;
        ts.getCurrent();
        pvTimeStamp.set(ts);

        // example how to get EPICS time
        TimeStamp ts2;
        pvTimeStamp.get(ts2);
        testOk1(ts2.getEpicsSecondsPastEpoch() != 0);
    }
    else
        testFail("timeStamp attach fail");

    //
    // alarm ops
    //
    PVAlarm pvAlarm;
    if (ntScalarArray->attachAlarm(pvAlarm))
    {
        testPass("alarm attach");

        // example how to set an alarm
        Alarm alarm;
        alarm.setStatus(deviceStatus);
        alarm.setSeverity(minorAlarm);
        alarm.setMessage("simulation alarm");
        pvAlarm.set(alarm);
    }
    else
        testFail("alarm attach fail");

    //
    // display ops
    //
    PVDisplay pvDisplay;
    if (ntScalarArray->attachDisplay(pvDisplay))
    {
        testPass("display attach");

        // example how to set an display
        Display display;
        display.setLow(-15);
        display.setHigh(15);
        display.setDescription("This is a test scalar array");
        display.setFormat("%d");
        display.setUnits("A");
        pvDisplay.set(display);
    }
    else
        testFail("display attach fail");

    //
    // control ops
    //
    PVControl pvControl;
    if (ntScalarArray->attachControl(pvControl))
    {
        testPass("control attach");

        // example how to set an control
        Control control;
        control.setLow(-10);
        control.setHigh(10);
        control.setMinStep(1);
        pvControl.set(control);
    }
    else
        testFail("control attach fail");

    //
    // set descriptor
    //
    ntScalarArray->getDescriptor()->put("This is a test NTScalarArray");

    // dump ntScalarArray
    std::cout << *ntScalarArray->getPVStructure() << std::endl;

}