Beispiel #1
0
void EditNoteDialog::setInputData()
{
    //initialize inputs for new note
    if (mode == CREATE_NEW)
    {
        //set date field value to selected date
        entryDate->set_text(selectedDate.toString());

        //initialize time field as current time +15min
        Glib::DateTime dateTime = Glib::DateTime::create_now_local().add_minutes(Preferences::prefs->getNewNoteMinutes());
        TimeValue timeValue = dateTime;
        entryTime->set_text(timeValue.toString());
    }

    //initialize inputs from existing note
    if (mode == EDIT)
    {
        entryTitle->set_text(noteData->getTitle());
        textDescription->get_buffer()->set_text(noteData->getDetails());
        entryDate->set_text(noteData->getDateText());
        entryTime->set_text(noteData->getTimeText());
        checkReminder->set_active(noteData->isReminder());
    }

}
Beispiel #2
0
// poll for writing
int Sock::poll_out(TimeValue &timeout)
{
#ifndef _WIN32	
	struct pollfd pollset[1];
	pollset[0].fd = sockfd;
	pollset[0].events = POLLOUT|POLLERR;
	pollset[0].revents = 0;
	int result =  ::poll(pollset, 1, timeout.msec());
	if (result > 0)
		return pollset[0].revents;
	else
		return result;
#else
	fd_set fds_write, fds_err;
	 FD_ZERO(&fds_write);
	 FD_ZERO(&fds_err);
	 FD_SET(sockfd, &fds_write);
	 FD_SET(sockfd, &fds_err);

	 int result = ::select(0, NULL, &fds_write, &fds_err, timeout.timeval());
	 if (result <= 0)
	 	return result;
	 unsigned revents = 0;
	if (FD_ISSET(sockfd, &fds_write)) revents |= POLLOUT;
	if (FD_ISSET(sockfd, &fds_err)) revents |= POLLERR;
	return revents;
#endif
}
int32 RTD::StopMeasurement(void)
{
    TimeValue StopTime;

    StopTime.set_to_current_time();
    return (StopTime.to_msec() - StartTime.to_msec());
}
Beispiel #4
0
//----------------------------------------------------------------------
// All logging eventually boils down to this function call. If we have
// a callback registered, then we call the logging callback. If we have
// a valid file handle, we also log to the file.
//----------------------------------------------------------------------
void
Log::VAPrintf(const char *format, va_list args)
{
    // Make a copy of our stream shared pointer in case someone disables our
    // log while we are logging and releases the stream
    StreamSP stream_sp(m_stream_sp);
    if (stream_sp)
    {
        static uint32_t g_sequence_id = 0;
        StreamString header;

        // Add a sequence ID if requested
        if (m_options.Test (LLDB_LOG_OPTION_PREPEND_SEQUENCE))
            header.Printf ("%u ", ++g_sequence_id);

        // Timestamp if requested
        if (m_options.Test (LLDB_LOG_OPTION_PREPEND_TIMESTAMP))
        {
            TimeValue now = TimeValue::Now();
            header.Printf ("%9d.%09.9d ", now.seconds(), now.nanoseconds());
        }

        // Add the process and thread if requested
        if (m_options.Test (LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD))
            header.Printf ("[%4.4x/%4.4" PRIx64 "]: ", getpid(), Host::GetCurrentThreadID());

        // Add the thread name if requested
        if (m_options.Test (LLDB_LOG_OPTION_PREPEND_THREAD_NAME))
        {
            llvm::SmallString<32> thread_name;
            ThisThread::GetName(thread_name);
            if (!thread_name.empty())
                header.Printf ("%s ", thread_name.c_str());
        }

        header.PrintfVarArg (format, args);
        header.PutCString("\n");

        if (m_options.Test(LLDB_LOG_OPTION_BACKTRACE)) 
        {
            std::string back_trace;
            llvm::raw_string_ostream stream(back_trace);
            llvm::sys::PrintStackTrace(stream);
            header.PutCString(back_trace.c_str());
        }

        if (m_options.Test(LLDB_LOG_OPTION_THREADSAFE))
        {
            static Mutex g_LogThreadedMutex(Mutex::eMutexTypeRecursive);
            Mutex::Locker locker(g_LogThreadedMutex);
            stream_sp->PutCString(header.GetString().c_str());
            stream_sp->Flush();
        }
        else
        {
            stream_sp->PutCString(header.GetString().c_str());
            stream_sp->Flush();
        }
    }
}
Beispiel #5
0
int64_t HeapTimer::RegisterTimer(const TimeValue& interval,
        const TimeValue& delay,
        CallbackObject* cb_obj,
        void* data)
{
    if (interval.Sec() == 0 && interval.Usec() == 0)
        return -1;

    if (cur_size_ >= heap_size_)
        return -1;

    TimerNode* new_node = new TimerNode;
    if (new_node == NULL)
        return -1;

    new_node->cb_obj            = cb_obj;
    new_node->data              = data;
    new_node->timer_id          = PopFreeTimerId();
    new_node->interval_time     = interval;
    new_node->expire_time       = ExpireTime(TimeValue(time(NULL)), delay);

    if (cur_size_ + 2 >= heap_size_)
        GrowHeap();

    RotateUp(new_node, cur_size_, GetParentPos(cur_size_));
    cur_size_++;

    LOG(INFO) << "RegisterTimer TimerSize[" << GetTimerSize() << "] TimerId[" << new_node->timer_id <<"]";

    return new_node->timer_id;
}
Beispiel #6
0
void rtc_callback_function()
{
    timeValue.DecreaseSecond(false);

    sevenSegmentDisplay.SetTime(timeValue);

    if (timeValue.IsValid() == false)
    {
        StopCountDownTimer();
    }
}
uint16_t ConnectionFileDescriptor::GetListeningPort(uint32_t timeout_sec)
{
    uint16_t bound_port = 0;
    if (timeout_sec == UINT32_MAX)
        m_port_predicate.WaitForValueNotEqualTo (0, bound_port);
    else
    {
        TimeValue timeout = TimeValue::Now();
        timeout.OffsetWithSeconds(timeout_sec);
        m_port_predicate.WaitForValueNotEqualTo (0, bound_port, &timeout);
    }
    return bound_port;
}
void
RoutingStatsScene::addRp(uint32_t nodeId, QString destination, qreal time, RoutePathElementsVector_t elements)
{
    NodeIdDest_t nd = { nodeId, destination };
    if(m_rps.find(nd) == m_rps.end())
    {
        TimeValue <RoutePathElementsVector_t> tv;
        tv.add(time, elements);
        m_rps[nd] = tv;
        return;
    }
    TimeValue <RoutePathElementsVector_t> & tv = m_rps[nd];
    tv.add(time, elements);
}
void
RoutingStatsScene::add(uint32_t nodeId, qreal time, QString rt)
{
    if(m_nodeIdTimeValues.find(nodeId) == m_nodeIdTimeValues.end())
    {
        TimeValue <QString> tv;
        tv.add(time, rt);
        m_nodeIdTimeValues[nodeId] = tv;
        addToProxyWidgetsMap(nodeId, "", rt);
        return;
    }
    TimeValue <QString> & tv = m_nodeIdTimeValues[nodeId];
    tv.add(time, rt);

}
void
PacketsScene::addPackets ()
{
  bool foundNodes = setUpNodeLines ();
  if (!foundNodes)
    return;
  Table * table = PacketsMode::getInstance ()->getTable ();
  table->removeAllRows ();
  uint32_t count = 0;
  uint32_t maxPackets = 10000;

  if (m_packetPathItem)
    {
      removeItem (m_packetPathItem);
    }
  m_packetPathItem = new QGraphicsPathItem;
  addItem (m_packetPathItem);
  m_packetPath = QPainterPath ();
  TimeValue <AnimEvent*> *events = AnimatorMode::getInstance ()->getEvents ();
  for (TimeValue<AnimEvent *>::TimeValue_t::const_iterator i = events->Begin ();
      i != events->End ();
      ++i)
    {
      AnimEvent * ev = i->second;
      if (ev->m_type == AnimEvent::PACKET_FBTX_EVENT)
        {
          AnimPacketEvent * packetEvent = static_cast<AnimPacketEvent *> (ev);
          if (!isAllowedNode (packetEvent->m_fromId))
            continue;
          if (!isAllowedNode (packetEvent->m_toId))
            continue;
          if (packetEvent->m_fbRx > m_toTime)
              continue;
          if (packetEvent->m_fbTx < m_fromTime)
              continue;

          if ((count == maxPackets) && m_showGraph)
            AnimatorMode::getInstance ()->showPopup ("Currently only the first " + QString::number (maxPackets) + " packets will be shown. Table will be fully populated");
          addPacket (packetEvent->m_fbTx, packetEvent->m_fbRx, packetEvent->m_fromId, packetEvent->m_toId, packetEvent->m_metaInfo, count < maxPackets );
          AnimatorMode::getInstance ()->keepAppResponsive ();
          ++count;

        }
    }
  table->adjust ();
  m_infoWidget->setVisible (false);

}
Beispiel #11
0
//----------------------------------------------------------------------
// All logging eventually boils down to this function call. If we have
// a callback registered, then we call the logging callback. If we have
// a valid file handle, we also log to the file.
//----------------------------------------------------------------------
void
Log::PrintfWithFlagsVarArg (uint32_t flags, const char *format, va_list args)
{
    // Make a copy of our stream shared pointer in case someone disables our
    // log while we are logging and releases the stream
    StreamSP stream_sp(m_stream_sp);
    if (stream_sp)
    {
        static uint32_t g_sequence_id = 0;
        StreamString header;
		// Enabling the thread safe logging actually deadlocks right now.
		// Need to fix this at some point.
//        static Mutex g_LogThreadedMutex(Mutex::eMutexTypeRecursive);
//        Mutex::Locker locker (g_LogThreadedMutex);

        // Add a sequence ID if requested
        if (m_options.Test (LLDB_LOG_OPTION_PREPEND_SEQUENCE))
            header.Printf ("%u ", ++g_sequence_id);

        // Timestamp if requested
        if (m_options.Test (LLDB_LOG_OPTION_PREPEND_TIMESTAMP))
        {
            TimeValue now = TimeValue::Now();
            header.Printf ("%9d.%6.6d ", now.seconds(), now.nanoseconds());
        }

        // Add the process and thread if requested
        if (m_options.Test (LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD))
            header.Printf ("[%4.4x/%4.4" PRIx64 "]: ", getpid(), Host::GetCurrentThreadID());

        // Add the process and thread if requested
        if (m_options.Test (LLDB_LOG_OPTION_PREPEND_THREAD_NAME))
        {
            std::string thread_name (Host::GetThreadName (getpid(), Host::GetCurrentThreadID()));
            if (!thread_name.empty())
                header.Printf ("%s ", thread_name.c_str());
        }

        header.PrintfVarArg (format, args);
        stream_sp->Printf("%s\n", header.GetData());
        
        if (m_options.Test (LLDB_LOG_OPTION_BACKTRACE))
            Host::Backtrace (*stream_sp, 1024);
        stream_sp->Flush();
    }
}
void ConstraintPresenter::on_defaultDurationChanged(const TimeValue& val)
{
    auto width = val.toPixels(m_zoomRatio);
    m_view->setDefaultWidth(width);
    m_header->setWidth(width);

    if(rack())
    {
        rack()->setWidth(m_view->defaultWidth() - 20);
    }
}
Beispiel #13
0
void DataCollectorSolver::logQueryStats(const Query &query,
        QueryType type, TimeValue start, Solver::Validity validity) {
    int result;

    TimeValue duration = TimeValue::now() - start;
    std::string query_blob;
    std::pair<uint64_t, uint64_t> qids = serializer_.Serialize(query, query_blob);

    // Query structure
    sqlite3_clear_bindings(qinsert_stmt_);

    sqlite3_bind_int64(qinsert_stmt_, 1, qids.first);
    if (qids.second) {
        sqlite3_bind_int64(qinsert_stmt_, 2, qids.second);
    }
    sqlite3_bind_int64(qinsert_stmt_, 14,
            event_logger_->logEvent(g_s2e_state, EVENT_KLEE_QUERY, 1));

    sqlite3_bind_int(qinsert_stmt_, 3, query.constraints.head()->depth());
    sqlite3_bind_blob(qinsert_stmt_, 4,
            query_blob.c_str(), query_blob.size(), NULL);
    sqlite3_bind_int(qinsert_stmt_, 5, static_cast<int>(type));

    result = sqlite3_step(qinsert_stmt_);
    assert(result == SQLITE_DONE);
    sqlite3_reset(qinsert_stmt_);

    // Query results
    sqlite3_bind_int64(rinsert_stmt_, 1, qids.first);
    sqlite3_bind_int64(rinsert_stmt_, 2, duration.usec());
    if (type == TRUTH || type == VALIDITY) {
        sqlite3_bind_int(rinsert_stmt_, 3, static_cast<int>(validity));
    }
    result = sqlite3_step(rinsert_stmt_);
    assert(result == SQLITE_DONE);
    sqlite3_reset(rinsert_stmt_);
}
Beispiel #14
0
LNE_UINT ThreadMutex::Acquire(const TimeValue &tv)
{
	if(!IsAvailable())
		return LNERR_NOINIT;
#if defined(LNE_WIN32)
	DWORD ret = WaitForSingleObject(mutex_, (DWORD)tv.ToMillisecond());
	if(ret == WAIT_OBJECT_0)
		return LNERR_OK;
	if(ret == WAIT_TIMEOUT)
		return LNERR_TIMEOUT;
#else
	struct timespec ts;
	TimeValue dest;
	dest.Now();
	dest += tv;
	ts.tv_sec = dest.sec();
	ts.tv_nsec = dest.usec() * 1000;
	if(pthread_mutex_timedlock(&mutex_, &ts) == 0)
		return LNERR_OK;
	if(errno == ETIMEDOUT)
		return LNERR_TIMEOUT;
#endif
	return LNERR_UNKNOW;
}
Beispiel #15
0
void StopCountDownTimer()
{
    realTimeClock.Stop();

    uvLed.Stop();
    
    countDownTimerState = COUNT_DOWN_TIMER_STATE_STOPPED;

    timeValue.Reset();

    sevenSegmentDisplay.SetTime(timeValue);
    sevenSegmentDisplay.SetStandBy(true);

    beepBuzz = true;
}
Beispiel #16
0
void StartCountDownTimer()
{
    if (IsPauseSwitchOn() == true)
    {
        return;
    }

    if (timeValue.IsValid())
    {
        sevenSegmentDisplay.SetStandBy(false);

        countDownTimerState = COUNT_DOWN_TIMER_STATE_STARTED;

        realTimeClock.Start();

        uvLed.Start();
    }
    else
    {
        StopCountDownTimer();
    }
}
Beispiel #17
0
void Bullet::update(TimeValue time)
{
    if (isUpdating())
        dynamicsWorld_->stepSimulation(time.toSeconds(), 8, getSubstepSize().toSeconds());
}
void ConstraintPresenter::on_minDurationChanged(const TimeValue& min)
{
    m_view->setMinWidth(min.toPixels(m_zoomRatio));
}
void ConstraintPresenter::on_maxDurationChanged(const TimeValue& max)
{
    m_view->setMaxWidth(max.isInfinite(),
                        max.isInfinite()? -1 : max.toPixels(m_zoomRatio));
}
Beispiel #20
0
int	SockConnector::connect(SockStream &stream, InetAddr &addr, TimeValue &tv)
{	
	int rv = 0;

	// non-block socket
	stream.set_nonblocking();
	
	#ifdef _WIN32

	// connect
	rv = ::connect(stream.get_handle(), (const struct sockaddr *) addr.get_addr(), (socklen_t)addr.get_addr_size());
	if (rv != -1) {
		rv = 0;
	}
	else  {
		if (WSAGetLastError() == WSAEWOULDBLOCK) 
		{
			//printf("connect InProgress [%d]\n", sock);
			fd_set rset;
			fd_set wset;

			FD_ZERO(&rset);
			FD_ZERO(&wset);
			FD_SET(stream.get_handle(), &rset);			
			FD_SET(stream.get_handle(), &wset);			
			
			rv = ::select(0, &rset, &wset, NULL, (struct  timeval*)tv.timeval());
			if (rv == 0) {				
				perror("connect timeout");
				rv = -1;
			}
			else if (FD_ISSET(stream.get_handle(), &rset) || FD_ISSET(stream.get_handle(), &wset)) {
				int error = 0;
				socklen_t len = sizeof(error);
				if (getsockopt(stream.get_handle(), SOL_SOCKET, SO_ERROR, (char *)&error, &len) == 0) {
					// select error
					if (error == 0) {
						rv = 0;
					}
					else {
						closesocket(stream.get_handle());						
						perror("connect");		
						rv = -1;
					}	
				}
			}
			else {
				perror("connect");		
				rv = -1;

			}
		} 
		else {
			perror("connect");
			rv = -1;
		}
	}
	#endif

	// restore file status flags
	stream.set_blocking();
	
	return rv;
}
Beispiel #21
0
//// Other conversions
inline OSSIA::TimeValue time(const TimeValue& t)
{
    return t.isInfinite()
            ? OSSIA::Infinite
            : OSSIA::TimeValue{t.msec()};
}
Beispiel #22
0
void View::setDefaultDuration(const TimeValue& t)
{
    auto qtime = t.toQTime();
    if(qtime != m_defaultDur->time())
        m_defaultDur->setTime(qtime);
}
Beispiel #23
0
void ProcessKey()
{
    if (current_key != KEY_NONE)
    {
        switch (current_key)
        {
            case KEY_TIMER_PRESET:
            {
                if(countDownTimerState == COUNT_DOWN_TIMER_STATE_STOPPED)
                {
                    sevenSegmentDisplay.SetStandBy(false);
                    timeValue.Reset();

                    if (preset_idx == sizeof(preset_time)/sizeof(uint8_t))
                    {
                        preset_idx = 0;
                    }

                    for (int i = 0; i < preset_time[preset_idx]; i++)
                    {
                        timeValue.IncreaseMinute();
                    }

                    sevenSegmentDisplay.SetTime(timeValue);
                    preset_idx++;
                }
            }
            break;

            case KEY_START_STOP:
            {
                /*
                * If already stopped then start it
                **/
                if (countDownTimerState == COUNT_DOWN_TIMER_STATE_STOPPED)
                {
                    StartCountDownTimer();
                }
                else if(countDownTimerState == COUNT_DOWN_TIMER_STATE_STARTED)
                {
                    /*
                    * If already started then stop it
                    **/
                    StopCountDownTimer();
                }
            }
            break;

            case KEY_TIMER_UP:
            {
                if(countDownTimerState == COUNT_DOWN_TIMER_STATE_STOPPED)
                {
                    sevenSegmentDisplay.SetStandBy(false);

                    if (minuteSelect == true)
                    {
                        timeValue.IncreaseMinute();
                    }
                    else
                    {
                        for (unsigned char i = 0; i < 10; i++)
                        {
                            timeValue.IncreaseSecond();
                        }
                    }
                    sevenSegmentDisplay.SetTime(timeValue);
                }
            }
            break;

            case KEY_TIMER_DOWN:
            {
                if(countDownTimerState == COUNT_DOWN_TIMER_STATE_STOPPED)
                {
                    sevenSegmentDisplay.SetStandBy(false);

                    if (minuteSelect == true)
                    {
                        timeValue.DecreaseMinute();
                    }
                    else
                    {
                        /* increase second in multiples of 10*/
                        for (unsigned char i = 0; i < 10; i++)
                        {
                            timeValue.DecreaseSecond();
                        }
                    }
                    sevenSegmentDisplay.SetTime(timeValue);
                }
            }
            break;

            case KEY_TIMER_MINUTE_SELECT:
            {
                if(countDownTimerState == COUNT_DOWN_TIMER_STATE_STOPPED)
                {
                    minuteSelect = !minuteSelect;
                }
            }
            break;
        }

        current_key = KEY_NONE;
    }
}
Beispiel #24
0
void EditNoteDialog::verifyInputData()
{
    const Glib::ustring title = entryTitle->get_text();
    const Glib::ustring desc = textDescription->get_buffer()->get_text(false);
    const Glib::ustring date = entryDate->get_text();
    const Glib::ustring time = entryTime->get_text();
    const bool isReminder = checkReminder->get_active();

    bool title_valid = false;
    bool date_valid = false;
    bool time_valid = false;

    //check title
    if (title.length() > 0)
    {
        title_valid = true;
    }

    //check date
    DateValue dateValue;
    if (dateValue.parseString(date))
    {
        date_valid = true;
    }

    //check time
    TimeValue timeValue;
    if (timeValue.parseString(time))
    {
        time_valid = true;
    }

    if (title_valid && date_valid && time_valid)
    {
        isInputDataValid = true;

        btnSave->set_sensitive(true);
        infoBar->setText(Gtk::MESSAGE_INFO, lang::getString(lang::EDIT_NOTE_INPUT_VALIDATED));

        //update note data
        noteData->setDate(dateValue);
        noteData->setTime(timeValue);
        noteData->setReminder(isReminder);
        noteData->setTitle(title);
        noteData->setDetails(desc);
    }
    else
    {
        isInputDataValid = false;

        btnSave->set_sensitive(false);

        std::string message = lang::getString(lang::EDIT_NOTE_INPUT_NOT_VALIDATED);

        if (!title_valid)
            message = lang::getString(lang::EDIT_NOTE_INPUT_CORRECT_TITLE);

        if (title_valid && !date_valid)
            message = lang::getString(lang::EDIT_NOTE_INPUT_CORRECT_DATE);

        if (title_valid && date_valid && !time_valid)
            message = lang::getString(lang::EDIT_NOTE_INPUT_CORRECT_TIME);

        infoBar->setText(Gtk::MESSAGE_ERROR, message);
    }
}