本文整理汇总了C++中Alarm类的典型用法代码示例。如果您正苦于以下问题:C++ Alarm类的具体用法?C++ Alarm怎么用?C++ Alarm使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Alarm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: min
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: deviceRemoved
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: main
int main(int argc,char *argv[])
{
QApplication app(argc,argv);
Alarm alarm;
alarm.show();
return app.exec();
};
示例4: while
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;
}
示例5: read_file
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;
}
示例6: get
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());
}
示例7: while
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);
}
示例8: UpdateItem
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);
}
示例9: UpdateStatus
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);
}
示例10: set
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;
}
示例11: while
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);
}
示例12: Alarm_process
// 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);
}
}
示例13: decodeText
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 );
}
}
示例14: KDateTime
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;
}
示例15: cancel_sig
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();
}
}