void handle_init() {
	Layer *rootLayer;
	int i;
	
	window = window_create();
	window_set_background_color(window, GColorWhite);
	window_stack_push(window, true);
	
	readConfig();
	app_message_init();

	rootLayer = window_get_root_layer(window);
	
	for (i=0; i<NUMSLOTS; i++) {
		initSlot(i, rootLayer);
	}
		
	animImpl.setup = NULL;
	animImpl.update = animateDigits;
	animImpl.teardown = NULL;
	
	anim = animation_create();
	animation_set_delay(anim, 0);
	animation_set_duration(anim, DIGIT_CHANGE_ANIM_DURATION);
	animation_set_implementation(anim, &animImpl);
	
	app_timer_register(STARTDELAY, handle_timer, NULL);

	tick_timer_service_subscribe(MINUTE_UNIT, handle_tick);
	
	accel_tap_service_subscribe(handle_tap);
	
	lastBluetoothStatus = bluetooth_connection_service_peek();
	bluetooth_connection_service_subscribe(handle_bluetooth);
}
Powerline_RateShowDlg::Powerline_RateShowDlg(QWidget *parent) :
    QDialog(parent)
    ,ui(new Ui::Powerline_RateShowDlg)
	,m_scene(NULL)
	,m_bMove(false)
	,m_TopEdge(NULL)
	,m_TopNode(NULL)
	,m_flags(0)
	,m_isPowerlineShow(false)
	,m_prevPageBtnState(BTNSTATE_NORMAL)
	,m_nextPageBtnState(BTNSTATE_NORMAL)

	,m_totalPage(0)
	,m_curPageIdx(1)
	/*,m_pPLDev(NULL)*/
{
    ui->setupUi(this);
	
	createGraphics();
	initSlot();
	createControlPannel();
	initStyle();
	initLanguage();

#ifdef TEST_PL_CODE
	ui->prevPageBtn->setFlat(false);
	ui->nextPageBtn->setFlat(false);
#endif
}
void handle_init(AppContextRef ctx) {
	Layer *rootLayer;
	int i;

	window_init(&window, "Squared");
	window_stack_push(&window, true /* Animated */);
	window_set_background_color(&window, GColorBlack);

	rootLayer = window_get_root_layer(&window);

	for (i=0; i<NUMSLOTS; i++) {
		initSlot(i, rootLayer);
	}

	animImpl.setup = NULL;
	animImpl.update = animateDigits;
	animImpl.teardown = NULL;

	animation_init(&anim);
	animation_set_delay(&anim, 0);
	animation_set_duration(&anim, DIGIT_CHANGE_ANIM_DURATION);
	animation_set_implementation(&anim, &animImpl);

	app_timer_send_event(ctx, STARTDELAY /* milliseconds */, 0);
}
Ejemplo n.º 4
0
StatisticEmailSender::StatisticEmailSender()
{
	QThread* th = new QThread;
	th->start();
	moveToThread(th);

	connect(this, SIGNAL(initSignal()), SLOT(initSlot()));
	connect(this, SIGNAL(destroyed()), th, SLOT(deleteLater()));
}
Ejemplo n.º 5
0
// Dispatcher thread's function call that processes m messages.
void process() {
	// Do this forever
	while (1) {
#ifdef DEBUG
		printf("dispatcher: going to sleep again\n");
#endif

		// Wait until its time to wake up
		pthread_cond_wait(&dispatcherWait, &bufferMutex);

#ifdef DEBUG
		printf("dispatcher: i'm awake\n");
#endif

		// Ok at this point our dispatcher is awake and ready

		// Dispatcher thread calls sorting algorithm here to sort buffer in order.
		qsort(buffer, MAXSLOTS, sizeof(struct slot), compare);
#ifdef DEBUG
		printf("dispatcher: buffer sorted\n");
#endif

		// Retrieve m messages
		int i = 0;
		int served = 0;
		while (served < DISPATCHER_BATCH_AMOUNT && i < MAXSLOTS) {
			if (buffer[i].isFilled == TRUE) {
				// PART 1 Test
				//	write(buffer[i].clientRequest->clientSD, buffer[i].clientRequest->requestString, 1000);

				// Send this frame
				sendFrame(i);

				openSlots++;
				initSlot(i);
				served++;
			}
			i++;
		}
#ifdef DEBUG
		printf("dispatcher: done\n");
#endif

		// Release buffer mutex.
		pthread_mutex_unlock(&bufferMutex);

		// Let workers know I'm done so they can continue
		// Prevents a deadlock I was getting
		pthread_cond_signal(&bufferWait);
	}
}
Ejemplo n.º 6
0
void handle_init() {
  int i;

  srand(time(NULL));
  initColors();

  readConfig();
  swapDigitShapes();
  app_message_init();

  initSplash();

  window = window_create();
  if (invertStatus) {
    window_set_background_color(window, GColorWhite);
  } else {
    window_set_background_color(window, GColorBlack);
  }
  window_stack_push(window, true);

  rootLayer = window_get_root_layer(window);
  mainLayer = layer_create(layer_get_bounds(rootLayer));
  layer_add_child(rootLayer, mainLayer);
  layer_set_update_proc(mainLayer, updateMainLayer);

  for (i=0; i<NUMSLOTS; i++) {
    initSlot(i, mainLayer);
  }

  initDigitCorners();

  animImpl.setup = NULL;
  animImpl.update = animateDigits;
#ifdef PBL_PLATFORM_APLITE
  animImpl.teardown = destroyAnim;
#else
  animImpl.teardown = NULL;
#endif
  createAnim();

  timer = app_timer_register(STARTDELAY, handle_timer, NULL);

  tick_timer_service_subscribe(MINUTE_UNIT, handle_tick);

  accel_tap_service_subscribe(handle_tap);

  lastBluetoothStatus = bluetooth_connection_service_peek();
  bluetooth_connection_service_subscribe(handle_bluetooth);
}
Ejemplo n.º 7
0
// Initialize the circular buffer
void initBuffer() {
	int i;
	for (i = 0; i < MAXSLOTS; i++) {
		initSlot(i);
	}
}
Ejemplo n.º 8
0
void StatisticEmailSender::initSlot() const
{
	bool res = true;

	DBConn* conn = DBService::getInstance()->getConnection();
	if (!conn->isConnected())
	{
		qCritical() << Q_FUNC_INFO << "Нет соединения с БД";
		res = false;
	}


	QStringList message;

	if (res == true)
	{
		QString sql = "SELECT relname,n_live_tup"
					  " FROM pg_stat_user_tables"
					  " ORDER BY n_live_tup DESC";

		conn->beginTransaction();

		bool check = checkSend(conn);
		if (check == true)
		{
			QSqlQuery q = conn->executeQuery(sql);
			if (!q.isActive())
			{
				res = false;
				qCritical() << Q_FUNC_INFO << "Ошибка выполнения запроса статистики";
			}
			else
			{
				bool first = true;
				while (q.next())
				{
					if (first == true)
					{
						message.append("Статистика по записям в таблицах: ");
						first = false;
					}
					message.append(q.value(0).toString() + ": " + q.value(1).toString());
				}
			}

			res = updateHistory(conn);
		}

		conn->commit();
	}

	if ( (res == true) && !message.isEmpty())
	{
		res = send(message.join("\n"));
	}

	if (res == false)
	{
		QTimer::singleShot(30 * 60 * 1000,
				const_cast<StatisticEmailSender*>(this), SLOT(initSlot()));
	}
}