コード例 #1
0
ファイル: uiViewInit.c プロジェクト: elmux/yacm
/**
 * run action of init view
 */
static void run(void) {
    char initMessage[40] = "Initializing";
    if (isTimerElapsed(initTimer)) {

        /* set new timer */
        initTimer = setUpTimer(RUN_INTERVAL);
        if (intervals < 25) {
            intervals++;
        }
        for (int i = 1; i < intervals; i++) {
            strcat(initMessage,".");
        }
        DisplayState *displaystate = getDisplayState();

        /* Select fonts */
        displaystate->font = GrCreateFont((unsigned char *) FONTNAME, 14, NULL);
        GrSetGCFont(displaystate->gContextID, displaystate->font);
        GrText(displaystate->gWinID, displaystate->gContextID, 120, 30, initMessage, -1, GR_TFASCII | GR_TFTOP);
        GrDestroyFont(displaystate->font);
    }
    /* Did someone turn the coffeemaker off? */
    if (getSwitchState(POWER_SWITCH) == switch_off) {
#ifdef DEBUG
        printf("Detected power switch to off\n");
#endif
        switchOff();
    }
}
コード例 #2
0
ファイル: GM862.cpp プロジェクト: stmpy/B-line-Security
int GM862::executeCommand(String command){
    //  Serial.println("command: '" + command + "'\nlength: " + command.length());
	// parse command and execute
	int state = -1;
    if(command.equalsIgnoreCase("reboot")){
	  switchOff();
	  delay(8000);
	  switchOn();
	  delay(16000);
	  init();
	  state = 97;
	} else if(command.equalsIgnoreCase("delete messages")){
	  deleteMessage("0");
	  state = 96;
	} else if(command.equalsIgnoreCase("help")){
	  state = 95;
	}
	for(int i=0;i<=numOfCommands;i++){
//	   Serial.println("'" + command + "' ?? '" + commands[i] + "'");
	   if(command.equalsIgnoreCase(commands[i])){
	       state = i;
	       break;
	   }
	}
    return state;
}
コード例 #3
0
LedDeviceTinkerforge::~LedDeviceTinkerforge()
{
	// Close the device (if it is opened)
	if (_ipConnection != nullptr && _ledStrip != nullptr)
	{
		switchOff();
	}

	// Clean up claimed resources
	delete _ipConnection;
	delete _ledStrip;
}
コード例 #4
0
/*** CONSTRUCTEUR ***/
Ihm::Ihm(Server *server, QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Ihm)
{
    ui->setupUi(this);
    pDynamique = new Dynamique;
    pBdd = new Bdd;

    _server = server;
    ui->addressLineEdit->setText(server->address());
    ui->portSpinBox->setValue(server->port());

    connect(ui->onPushButton, SIGNAL(clicked()), this, SLOT(onPushButton_clicked()));
    connect(ui->offPushButton, SIGNAL(clicked()), _server, SLOT(switchOff()));

    connect(ui->addressLineEdit, SIGNAL(textChanged(QString)), this, SLOT(addressLineEdit_textEdited(QString)));
    connect(ui->portSpinBox, SIGNAL(valueChanged(QString)), _server, SLOT(setPort(QString)));

    connect(server, SIGNAL(sig_switchedOn()), this, SLOT(server_switchedOn()));
    connect(server, SIGNAL(sig_switchedOff()), this, SLOT(server_switchedOff()));
    connect(server, SIGNAL(sig_switchedOffOnError(QString)), this, SLOT(server_switchedOffOnError(QString)));

    connect(server, SIGNAL(sig_addressChanged(QString)), this, SLOT(server_addressChanged(QString)));
    connect(server, SIGNAL(sig_portChanged(quint16)), this, SLOT(server_portChanged(quint16)));

    connect(server, SIGNAL(sig_newConnection(const ClientConnection&)), this, SLOT(server_newConnection(const ClientConnection&)));


    //réception signal homme en danger
    connect(this, SIGNAL(signalHommeEnDanger(QString &)), this, SLOT(hommeEnDanger(QString &)));
    //réception signal perte réceptin
    connect(this, SIGNAL(signalPerteReception(int, int, T_ListeLabel *)), this, SLOT(perteReception(int, int, T_ListeLabel *)));

    //obtention du nombre de vue max
    int vueMax = pBdd->getVueMax();

    //déclaration QList
    QList<T_TupleOnglet> listeTupleO;

    //récupération des infos sur les onglets
    pBdd->getVue(&listeTupleO);

    if(!listeTupleO.empty()){
        for(int i = 0; i < listeTupleO.count() && i < vueMax; i++) {
            int num_vue = listeTupleO.at(i).num_vue;
            QString legende = listeTupleO.at(i).legende;
            QString image = listeTupleO.at(i).image;
            //ajout de l'onglet
            this->ajoutOnglet(num_vue, legende, image);
        }
    }

    //supprimer les deux onglets de base
    ui->tabWidget->removeTab(0);
    ui->tabWidget->removeTab(vueMax);
    //mettre l'onglet de base dans la vue
    ui->tabWidget->setCurrentIndex(0);


    //régler les temps des timer en fonction de la base de données
    int tempoMouv; // ms tempo pour le timer mouvement
    int tempoRec; // ms tempo pour le timer de réception
    pBdd->getTempo(&tempoMouv, &tempoRec);
    this->setTempo(tempoMouv, tempoRec);


   // lecteurActif(pLecteur);     // à enlever à l'intégration
   // lecteurInactif(pLecteur);   // à enlever à l'intégration
   // lecteurInconnu();           // à enlever à l'intégration

   // traitementTrame("F60016A703");  //à enlever à l'intégration
   // traitementTrame("050026B102");  //à enlever à l'intégration
    //trame type : AD D01 6A7 01
    //AD niveau de reception
    //DO1 n° de badge
    //6A7 mouvement
    //01 n° lecteur

}
コード例 #5
0
ファイル: main.c プロジェクト: timex2000/avr-swim-watch
int main(void){
	state currentState = STATE_MM1;
	action actionToDo = NO_ACTION;
	
	// FSM state/action matrix
	stateElement stateMatrix[7][8] = {
		// MM1
		{{STATE_MM1, NO_ACTION}, {STATE_OFF, SWITCH_OFF}, {STATE_CHARGING, CHARGING}, {STATE_MM1, NO_ACTION}, {STATE_MM2, SHOW_MM2}, {STATE_MM2, SHOW_MM2}, {STATE_MM1, NO_ACTION}, {STATE_HISTORY, SHOW_HISTORY}},
		
		// OFF
		{{STATE_MM1, SHOW_MM1}, {STATE_OFF, NO_ACTION}, {STATE_OFF, NO_ACTION}, {STATE_OFF, NO_ACTION}, {STATE_OFF, NO_ACTION}, {STATE_OFF, NO_ACTION}, {STATE_OFF, NO_ACTION}, {STATE_OFF, NO_ACTION}},
		
		// CHARING
		{{STATE_CHARGING, NO_ACTION}, {STATE_CHARGING, NO_ACTION}, {STATE_CHARGING, NO_ACTION}, {STATE_MM1, SHOW_MM1}, {STATE_CHARGING, NO_ACTION}, {STATE_CHARGING, NO_ACTION}, {STATE_CHARGING, UPDATE_CHARGE}, {STATE_CHARGING, NO_ACTION}},
		
		// MM2
		{{STATE_MM2, NO_ACTION}, {STATE_OFF, SWITCH_OFF}, {STATE_CHARGING, CHARGING}, {STATE_MM2, NO_ACTION}, {STATE_MM1, SHOW_MM1}, {STATE_MM1, SHOW_MM1}, {STATE_MM2, NO_ACTION}, {STATE_RECORD, SHOW_RECORD}},
		
		// HISTORY
		{{STATE_HISTORY, NO_ACTION}, {STATE_OFF, SWITCH_OFF}, {STATE_CHARGING, CHARGING}, {STATE_HISTORY, NO_ACTION}, {STATE_SHOWLAP, SHOW_NEXT_LENGTH}, {STATE_SHOWLAP, SHOW_PREV_LENGTH}, {STATE_HISTORY, NO_ACTION}, {STATE_MM1, SHOW_MM1}},
		
		// SHOWLAP
		{{STATE_SHOWLAP, NO_ACTION}, {STATE_OFF, SWITCH_OFF}, {STATE_CHARGING, CHARGING}, {STATE_HISTORY, NO_ACTION}, {STATE_SHOWLAP, SHOW_NEXT_LENGTH}, {STATE_SHOWLAP, SHOW_PREV_LENGTH}, {STATE_HISTORY, NO_ACTION}, {STATE_HISTORY, SHOW_HISTORY}},
		
		// RECORD
		{{STATE_RECORD, NO_ACTION}, {STATE_OFF, SWITCH_OFF}, {STATE_CHARGING, CHARGING}, {STATE_RECORD, NO_ACTION}, {STATE_MM1, SHOW_MM1}, {STATE_MM1, SHOW_MM1}, {STATE_RECORD, UPDATE_RECORD}, {STATE_RECORD, ADD_LENGTH}}
	};
	
	initSystem();
	showMM1();
	
	while(1){
		event e = getEvent();
		
		// Obtain the next action
		stateElement stateEvaluation = stateMatrix[currentState][e];
		currentState = stateEvaluation.nextState;
		actionToDo = stateEvaluation.actionToDo;
		
		switch(actionToDo){
			case NO_ACTION:
				break;
			case SHOW_MM1:
				getBatteryPercentage();
				showMM1();
				break;
			case SWITCH_OFF:
				getBatteryPercentage();
				showOffScreen();
				_delay_ms(2000);
				switchOff();
				break;
			case CHARGING:
				initTimer();
				getBatteryPercentage();
				showChargingScreen();
				break;
			case SHOW_MM2:
				getBatteryPercentage();
				showMM2();
				break;
			case UPDATE_CHARGE:
				getBatteryPercentage();
				showChargingScreen();
				break;
			case SHOW_HISTORY:
				showHistoryTotal();
				break;
			case SHOW_NEXT_LENGTH:
				getNextLength();
				showLength();
				break;
			case SHOW_PREV_LENGTH:
				getPreviousLength();
				showLength();
				break;
			case SHOW_RECORD:
				initTimer();
				currentLength = 0;
				totLenTime = 0;
				showRecordScreen();
				break;
			case UPDATE_RECORD:
				totLenTime++;
				curLenTime++;
				showRecordScreen();
				break;
			case ADD_LENGTH:
				//curLenTime = 0;
				recordCurrentLength();
				showRecordScreen();
				break;
			default:
				break;
		}
	}
}
コード例 #6
0
ファイル: Socket.cpp プロジェクト: stadtmueller/pihoco
void Socket::off()
{
    std::cout << id << ": Off" << std::endl;
    state = 0;
    switchOff( systemCode, unitCode );
}