Esempio n. 1
0
void UndoBuffer::redo()
{
    if (locked)
	return;

    if (history_position >= history.size())
    {
	set_status("Nothing to redo");
	return;
    }

    StatusDelay delay("Redoing " + redo_action());

    // Redo next command and restore state
    bool have_command = history[history_position].has_command();

    process_state(history_position);
    if (!have_command)
	process_frame(history_position);
    process_pos(history_position);
    bool ok = process_command(history_position);

    if (!ok)
	delay.outcome = "failed";
    
    history_position++;

    done(&delay);
}
Esempio n. 2
0
/**
 * @brief Login::do_login
 *      Sets all UI parameters and calls a function to proceed according to the state of the login.
 * @param username
 * @param password
 * @param proxy_hostname
 * @param proxy_hostport
 * @param proxy_username
 * @param proxy_password
 * @date
 *      Created:  Filipe, 2 Jan 2014
 *      Modified: Filipe, 7 Mar 2014
 */
void Login::do_login(const QVariantHash &options)
{
    //Password or user change, the process has to be repeted.
    if(username != options.value("username").toString() || password != options.value("password").toString())
    {
        state = persistent;
        username = options.value("username").toString();
        password = options.value("password").toString();
    }

    //Set proxy settings.
    if(options.value("proxy_hostname", "").toString() != "" || options.value("proxy_hostport", "").toString() != "")
    {
        network_manager->set_proxy(Helper::proxy_type(options.value("proxy_type").toString()),
                                   options.value("proxy_hostname").toString(),
                                   options.value("proxy_hostport").toInt(),
                                   options.value("proxy_username").toString(),
                                   options.value("proxy_password").toString());
    }
    else
    {
        network_manager->set_proxy(QNetworkProxy::NoProxy);
    }

    output(network_manager->print(), 3);

    //Set captcha and steamguard code.
    captcha_text = options.value("captcha").toString();
    guard_code = options.value("guard_code").toString();
    guard_name = options.value("guard_name").toString();
    remember_login = options.value("remember_login").toBool();

    //Proceed acording to state.
    process_state();
}
Esempio n. 3
0
// Undo and redo commands
void UndoBuffer::undo()
{
    if (locked)
	return;

    if (history_position == 0)
    {
	set_status("Nothing to undo");
	return;
    }

    StatusDelay delay("Undoing " + undo_action());
   
    // Undo most recent command
    bool have_command = history[history_position - 1].has_command();

    bool ok = process_command(history_position - 1);
    if (ok && history_position > 1)
    {
	if (!have_command)
	    process_frame(history_position - 2);
	process_pos(history_position - 2);
	process_state(history_position - 2);
    }

    if (!ok)
	delay.outcome = "failed";

    history_position--;

    done(&delay);
}
Esempio n. 4
0
// the loop routine runs over and over again forever:
void loop() {
//digitalClockDisplay(hour(), minute());
	time_2 = millis();
	last_st = key_state;
	read_state();
	st = key_state;

	if (st != last_st) {
		process_state();
		process_display();
		time_1 = millis();
	} else if (menu_state == Menu0_MainMenu) {
		process_display(); // If Menu0, update display event without key_State
	}

	time = time_2 - time_1;
	time = time / 1000;
	if (time >= 10) {
		turnOffDisplay();
		resetKeyState();

		//pinMode(LCDBacklight_pin, OUTPUT);
		//DisplayLCD_State = false;
	} else {
		turnOnDisplay();
		//pinMode(LCDBacklight_pin, INPUT);
		//DisplayLCD_State = true;
	}

	Alarm.delay(90); // wait one second between clock display
}
Esempio n. 5
0
/////////////////////////////////////////////////////
//WINHOLDEM RUNTIME ENTRY POINT
/////////////////////////////////////////////////////
OHUSER_API double process_message (const char* pmessage, const void* param) {
        if (pmessage==NULL) { return 0; }
        if (param==NULL) { return 0; }

        if (strcmp(pmessage,"state")==0) { 
                holdem_state *state = (holdem_state*) param;
				if (ClientStarted != true){ initClient(); }
			 return process_state( (holdem_state*)param ); 
        }

        if (strcmp(pmessage,"query")==0) { 
//              MessageBox(NULL, (LPCSTR) param, "query", MB_OK);
                return process_query( (const char*)param ); 
        }

		//pfgws is outdated now, use exportable functions like GetSymbolFromDll etc
        if (strcmp(pmessage,"pfgws")==0) {      
//              MessageBox(NULL, "pfgws", "MESSAGE", MB_OK);
                m_pget_winholdem_symbol = (pfgws_t)param;
                return 0;
        }

        if (strcmp(pmessage,"event")==0 && strcmp((const char *) param, "load")==0) { 
			if (ClientStarted != true){ initClient(); }
//              MessageBox(NULL, "event-load", "MESSAGE", MB_OK);
        }

        if (strcmp(pmessage,"event")==0 && strcmp((const char *) param, "unload")==0) { 
//              MessageBox(NULL, "event-unload", "MESSAGE", MB_OK);
        }

        return 0;
}
Esempio n. 6
0
/* called for each full received packet from the touchpad */
static void read_input(InputInfoPtr local)
{
	struct mtev_mtouch *mt = local->private;
	while (mtouch_read_synchronized_event(mt, local->fd)) {
		process_state(local, mt);
	}
}
Esempio n. 7
0
/////////////////////////////////////////////////////
// user.dll entry point
/////////////////////////////////////////////////////
USERDLL_API double process_message (const char* pmessage, const void* param) 
{
	if (pmessage==NULL) { return 0; }
	if (param==NULL) { return 0; }

	if (strcmp(pmessage,"state")==0) 
	{ 
		holdem_state *state = (holdem_state*) param;
//		CString s; 
//		s.Format("<%s>\nPOTS: %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f\nCOMMON: %d %d %d %d %d\n%d %d %d\n<%s> %d %.2f %d", 
//			state->m_title,
//			state->m_pot[0], state->m_pot[1], state->m_pot[2], state->m_pot[3], state->m_pot[4], 
//			state->m_pot[5], state->m_pot[6], state->m_pot[7], state->m_pot[8], state->m_pot[9],
//			state->m_cards[0], state->m_cards[1], state->m_cards[2], state->m_cards[3], state->m_cards[4],
//			state->m_is_playing, state->m_is_posting, state->m_dealer_chair,
//			state->m_player[4].m_name, state->m_player[4].m_name_known, state->m_player[4].m_balance, state->m_player[4].m_balance_known);
//		MessageBox(NULL, s, "state", MB_OK);

		return process_state( (holdem_state*)param ); 
	}

	if (strcmp(pmessage,"query")==0) 
	{ 
//		MessageBox(NULL, (LPCSTR) param, "query", MB_OK);
		return process_query( (const char*)param ); 
	}

	if (strcmp(pmessage,"pfgws")==0) 
	{	
//		MessageBox(NULL, "pfgws", "MESSAGE", MB_OK);
		p_get_symbol = (p_getsym_t)param;
		return 0;
	}

	if (strcmp(pmessage,"p_send_chat_message")==0) 
	{	
//		MessageBox(NULL, "p_send_chat_message", "MESSAGE", MB_OK);
		p_send_chat = (p_send_chat_t)param;
		return 0;
	}

	if (strcmp(pmessage,"event")==0 && strcmp((const char *) param, "load")==0) 
	{ 
//		MessageBox(NULL, "event-load", "MESSAGE", MB_OK);
	}

	if (strcmp(pmessage,"event")==0 && strcmp((const char *) param, "unload")==0) 
	{ 
//		MessageBox(NULL, "event-unload", "MESSAGE", MB_OK);
	}

	return 0;
}
Esempio n. 8
0
int preprocess_B(Instruction *out, Emulator *emul)
{
	SignExtend_plgtab(&out->imm);

	if(InITBlock(emul->it_state))
	{
		process_state(&emul->it_state, out->name_in, emul->dic->states_tab);
		out->it_flag = IN;
	}

	return 0;
}
Esempio n. 9
0
int preprocess_pop_push(Instruction *out, Emulator *emul)
{
	if(out->encoding != 3)
		preprocess_reglist(out);

	if(InITBlock(emul->it_state))
	{
		process_state(&emul->it_state, out->name_in, emul->dic->states_tab);
		out->it_flag = IN;
	}

	return 0;
}
Esempio n. 10
0
bool UndoBuffer::process_state(int entry)
{
    assert(OK());

    locked = true;

    current_entry = entry;
    bool ok = process_state(history[entry]);

    locked = false;

    return ok;
}
Esempio n. 11
0
/////////////////////////////////////////////////////
// user.dll entry point
/////////////////////////////////////////////////////
USERDLL_API double process_message (const char* pmessage, const void* param) 
{
	if (pmessage==NULL) { return 0; }
	if (param==NULL) { return 0; }

	if (strcmp(pmessage,"state")==0) 
	{ 
		holdem_state *state = (holdem_state*) param;

#ifdef OPT_DEMO_OUTPUT
		CString s; 
		s.Format("<%s>\nPOTS: %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f\nCOMMON: %d %d %d %d %d\n%d %d %d\n<%s> %d %.2f %d", 
			state->m_title,
			state->m_pot[0], state->m_pot[1], state->m_pot[2], state->m_pot[3], state->m_pot[4], 
			state->m_pot[5], state->m_pot[6], state->m_pot[7], state->m_pot[8], state->m_pot[9],
			state->m_cards[0], state->m_cards[1], state->m_cards[2], state->m_cards[3], state->m_cards[4],
			state->m_is_playing, state->m_is_posting, state->m_dealer_chair,
			state->m_player[4].m_name, state->m_player[4].m_name_known, state->m_player[4].m_balance, state->m_player[4].m_balance_known);
		MessageBox(NULL, s, "state", MB_OK);
#endif OPT_DEMO_OUTPUT

		return process_state( (holdem_state*)param ); 
	}

	if (strcmp(pmessage,"query")==0) 
	{ 
#ifdef OPT_DEMO_OUTPUT
		MessageBox(NULL, (LPCSTR) param, "query", MB_OK);
#endif OPT_DEMO_OUTPUT

		return process_query( (const char*)param ); 
	}

	if (strcmp(pmessage,"event")==0 && strcmp((const char *) param, "load")==0) 
	{ 
#ifdef OPT_DEMO_OUTPUT
		MessageBox(NULL, "event-load", "MESSAGE", MB_OK);
#endif OPT_DEMO_OUTPUT
	}

	if (strcmp(pmessage,"event")==0 && strcmp((const char *) param, "unload")==0) 
	{ 
#ifdef OPT_DEMO_OUTPUT
		MessageBox(NULL, "event-unload", "MESSAGE", MB_OK);
#endif OPT_DEMO_OUTPUT
	}

	return 0;
}
Esempio n. 12
0
int preprocess_sub_sp(Instruction *out, Emulator *emul)
{
	ZeroExtend_plgtab(&out->imm);

	if(InITBlock(emul->it_state))
	{
		process_state(&emul->it_state, out->name_in, emul->dic->states_tab);
		out->it_flag = IN;
	}

	if(out->encoding == 1)
		out->imm.plages->value <<= 2;  // décalage de 2 bits, cf spécifications

	return 0;
}
Esempio n. 13
0
int preprocess_ldr(Instruction *out, Emulator *emul)
{
	ZeroExtend_plgtab(&out->imm);

	if(InITBlock(emul->it_state))
	{
		process_state(&emul->it_state, out->name_in, emul->dic->states_tab);
		out->it_flag = IN;
	}

	if(out->encoding == 1 || out->encoding == 2)
		out->imm.plages->value <<= 2;

	return 0;
}
Esempio n. 14
0
static void reset_clocks(void)
{
	/* 4MHz MSI raw range 2*/
	struct rcc_clock_scale myclock_config = {
		.hpre = RCC_CFGR_HPRE_SYSCLK_NODIV,
		.ppre1 = RCC_CFGR_PPRE1_HCLK_NODIV,
		.ppre2 = RCC_CFGR_PPRE2_HCLK_NODIV,
		.voltage_scale = PWR_SCALE2,
		.flash_waitstates = FLASH_ACR_LATENCY_0WS,
		.apb1_frequency = 4194000,
		.apb2_frequency = 4194000,
		.msi_range = RCC_ICSCR_MSIRANGE_4MHZ,
	};
	rcc_clock_setup_msi(&myclock_config);

	/* buttons and uarts */
	rcc_periph_clock_enable(RCC_GPIOA);
	/* user feedback leds */
	rcc_periph_clock_enable(RCC_GPIOB);
	/* Enable clocks for USART2. */
	rcc_periph_clock_enable(RCC_USART2);
	/* And a timers for button presses */
	rcc_periph_clock_enable(RCC_TIM7);
}

int main(void)
{
	reset_clocks();
	gpio_setup();
	usart_setup();
	setup_buttons();
	setup_button_press_timer();
	printf("we're awake!\n");

	setup_rtc();
	setup_rtc_wakeup(1);

	while (1) {
		PWR_CR |= PWR_CR_LPSDSR;
		pwr_set_stop_mode();
		__WFI();
		reset_clocks();
		process_state(&state);
	}

	return 0;
}
Esempio n. 15
0
int preprocess_BL(Instruction *out, Emulator *emul)
{
	// Ji = not(S xor Ii)
	out->imm.plages[1].value = (~ (out->imm.plages[0].value ^ out->imm.plages[1].value) ) & 1;
	out->imm.plages[2].value = (~ (out->imm.plages[0].value ^ out->imm.plages[2].value) ) & 1;


	SignExtend_plgtab(&out->imm);

	if(InITBlock(emul->it_state))
	{
		process_state(&emul->it_state, out->name_in, emul->dic->states_tab);
		out->it_flag = IN;
	}

	return 0;
}
Esempio n. 16
0
void CStateMachine::Clock()
{
	t_sm_state old_state;
	t_sm_event event;
	bool state_entry;

	old_state = m_state;

	/* Process state change acording to event */
	if (!m_queue.empty()) {
		event = m_queue.front();
		m_queue.pop();
	} else {
		event = 0;
	}
	
	/* State changes can only happen here */
	wxMutexLocker lock(m_stateMutex);
	m_state = next_state( event );

//#if 0
	/* Debug */
	++m_clockCounter;
	state_entry = ( m_state != old_state ) || ( m_clockCounter == 1 );
	if( state_entry )
	{
		m_clocksInCurrentState = 0;
		printf( "%s(%04d): %d -> %d\n",
			(const char *)unicode2char(m_name),
			m_clockCounter, old_state, m_state);
	}
	++m_clocksInCurrentState;
//#endif

	/* Process new state entry */
	if( m_state < m_maxStates )
	{
		/* It should be ok to call Clock() recursively inside this
		 * procedure because state change has already happened. Also
		 * the m_state mutex is recursive. */
		process_state(m_state, state_entry);
	}
}
Esempio n. 17
0
/////////////////////////////////////////////////////
//WINHOLDEM RUNTIME ENTRY POINT
/////////////////////////////////////////////////////
WHUSER_API double process_message(const char* pmessage, const void* param)
{
    /*
    *
    */

    if(pmessage==NULL)
    {
        gLog.WriteLog(eSeverityError, eCatOHMessages, "pmessage==NULL.. \n");
        return 0;
    }
    if(param==NULL)
    {
        gLog.WriteLog(eSeverityError, eCatOHMessages, "param==NULL.. \n");
        return 0;
    }

    gLog.WriteLogNoHeading(eSeverityInfo, eCatGeneral, "PROCESS Message.. %s, Param: %s\n", pmessage, (const char*)param);

    if(strcmp(pmessage,"state")==0)
    {
        gLog.WriteLogNoHeading(eSeverityInfo, eCatOHMessages, "PROCESS STATE..\n\tParam: %s\n", (const char*)param);
        double ret = process_state( (holdem_state*)param );
        gLog.WriteLogNoHeading(eSeverityInfo, eCatOHMessages, "PROCESS STATE FINISHED.. %.2f\n", ret);
        return ret;
    }
    if(strcmp(pmessage,"query")==0)
    {
        gLog.WriteLogNoHeading(eSeverityInfo, eCatOHMessages, "RUN QUERY..\nParam: %s\n", (const char*)param);
        double ret = process_query((const char*)param);
        gLog.WriteLogNoHeading(eSeverityInfo, eCatOHMessages, "PROCESS QUERY FINISHED.. %.2f\n", ret);
        return ret;
    }
    if(strcmp(pmessage,"pfgws")==0)
    {
        gVars.m_pget_winholdem_symbol = (pfgws_t)param;
        return 0;
    }

    return 0;
}
Esempio n. 18
0
// Restore current program state
void UndoBuffer::restore_current_state()
{
    if (locked)
	return;

    assert(OK());

    if (!showing_earlier_state())
	return;

    StatusDelay delay("Restoring state");

    clear_after_position();

    if (history.size() > 0)
	process_state(history.size() - 1);

    history_position = history.size();

    done(&delay);
}
Esempio n. 19
0
bool gui_theme::load_ui_object(const string& type, const string& obj_filename) {
	xml::xml_doc ui_object_doc = x->process_file(oclraster::data_path(obj_filename), false); // TODO: DTD!
	if(!ui_object_doc.valid) {
		oclr_error("couldn't process ui object file %s!", obj_filename);
		return false;
	}
	
	const size_t obj_version = ui_object_doc.get<size_t>("a2e_ui_object.version");
	if(obj_version != A2E_UI_OBJECT_VERSION) {
		oclr_error("invalid ui object version: %u (should be %u)!",
				  obj_version, A2E_UI_OBJECT_VERSION);
		return false;
	}
	
	//
	const xml::xml_node* obj_node = ui_object_doc.get_node("a2e_ui_object");
	if(obj_node == nullptr || obj_node->children.empty()) {
		oclr_error("ui object \"%s\" is empty!", obj_filename);
		return false;
	}
	
	// process nodes
	gui_ui_object* obj { new gui_ui_object(type) };
	for(const auto& node : obj_node->children) {
		if(node.first == "state" && (*node.second)["type"] != "INVALID") {
			gui_ui_object::state* st = new gui_ui_object::state();
			process_state(st, node.second);
			obj->states.insert(make_pair((*node.second)["type"], unique_ptr<gui_ui_object::state>(st)));
		}
		else if(node.first[0] != '#') {
			oclr_error("unknown node \"%s\" in ui object \"%s\"!", node.first, obj_filename);
		}
	}
	ui_objects.insert(make_pair(type, unique_ptr<gui_ui_object>(obj)));
	return true;
}
Esempio n. 20
0
int preprocess_add_reg_16(Instruction *out, Emulator *emul)
{
	Plgtab rdntab;





	plgtabdup(&rdntab, &out->reg);

	rdntab.size = 2; // il ne doit pas prendre en compte la dernière case

	ZeroExtend_plgtab(&rdntab); // met la taille à 1 et concatène les valeurs binaires


	rdntab.plages = realloc(rdntab.plages, 2 * sizeof(Plage));

	if(rdntab.plages == NULL)
		return 2;

	rdntab.size = 2;

	rdntab.plages[1] = out->reg.plages[2];

	free(out->reg.plages);

	out->reg = rdntab;

	if(InITBlock(emul->it_state))
	{
		process_state(&emul->it_state, out->name_in, emul->dic->states_tab);
		out->it_flag = IN;
	}

	return 0;
}
Esempio n. 21
0
File: ps.c Progetto: Karthikvb/opsys
int main(int argc, char *argv[], char *envp[]) {
	process_state();
	return 0;
}
Esempio n. 22
0
/////////////////////////////////////////////////////
// user.dll entry point
/////////////////////////////////////////////////////
USERDLL_API double process_message (const char* pmessage, const void* param) 
{ 
	if (pmessage==NULL) { return 0; }
	
	inHandMsgNum++;
	isAllInMsg = false;
	
	//ensure files open
	if (!dumpOutFile.is_open()) {
	  //read config
	  getConfigValue("dumpOutFileName", dumpOutFileName);
	  getConfigValue("testfilesDir", testfilesDir);
	  dumpOutFile.open(dumpOutFileName.c_str());
	  initTestFilenameList();
	}
	

	if (strcmp(pmessage,"state")==0) 
	{ 
		std::cout << "process_message called with state" << std::endl;
		holdem_state *state = (holdem_state*) param;
//		CString s; 
//		s.Format("<%s>\nPOTS: %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f\nCOMMON: %d %d %d %d %d\n%d %d %d\n<%s> %d %.2f %d", 
//			state->m_title,
//			state->m_pot[0], state->m_pot[1], state->m_pot[2], state->m_pot[3], state->m_pot[4], 
//			state->m_pot[5], state->m_pot[6], state->m_pot[7], state->m_pot[8], state->m_pot[9],
//			state->m_cards[0], state->m_cards[1], state->m_cards[2], state->m_cards[3], state->m_cards[4],
//			state->m_is_playing, state->m_is_posting, state->m_dealer_chair,
//			state->m_player[4].m_name, state->m_player[4].m_name_known, state->m_player[4].m_balance, state->m_player[4].m_balance_known);
//		MessageBox(NULL, s, "state", MB_OK);

		return process_state( (holdem_state*)param ); 
	}

	if (strcmp(pmessage,"query")==0) 
	{ 
		std::cout << "process_message called with query " << (const char*) param << std::endl;
//		MessageBox(NULL, (LPCSTR) param, "query", MB_OK);
		return process_query( (const char*)param ); 
	}

	if (strcmp(pmessage,"pfgws")==0) 
	{	
//		MessageBox(NULL, "pfgws", "MESSAGE", MB_OK);
		p_get_symbol = (p_getsym_t)param;
		return 0;
	}

	if (strcmp(pmessage,"p_send_chat_message")==0) 
	{	
//		MessageBox(NULL, "p_send_chat_message", "MESSAGE", MB_OK);
		p_send_chat = (p_send_chat_t)param;
		return 0;
	}

	if (strcmp(pmessage,"event")==0 && strcmp((const char *) param, "load")==0) 
	{ 
//		MessageBox(NULL, "event-load", "MESSAGE", MB_OK);
	}

	if (strcmp(pmessage,"event")==0 && strcmp((const char *) param, "unload")==0) 
	{ 
//		MessageBox(NULL, "event-unload", "MESSAGE", MB_OK);
	}

	return 0;
}