void IRInstruction::convertToNop() { IRInstruction nop(Nop, marker()); // copy all but m_id, m_taken, m_listNode m_op = nop.m_op; m_typeParam = nop.m_typeParam; m_numSrcs = nop.m_numSrcs; m_srcs = nop.m_srcs; m_numDsts = nop.m_numDsts; m_dst = nop.m_dst; setTaken(nullptr); m_extra = nullptr; }
void IRInstruction::become(IRFactory& factory, IRInstruction* other) { assert(other->isTransient() || m_numDsts == other->m_numDsts); auto& arena = factory.arena(); // Copy all but m_id, m_taken.from, m_listNode, m_marker, and don't clone // dests---the whole point of become() is things still point to us. m_op = other->m_op; m_typeParam = other->m_typeParam; m_numSrcs = other->m_numSrcs; m_extra = other->m_extra ? cloneExtra(m_op, other->m_extra, arena) : nullptr; m_srcs = new (arena) SSATmp*[m_numSrcs]; std::copy(other->m_srcs, other->m_srcs + m_numSrcs, m_srcs); setTaken(other->taken()); }
IRInstruction::IRInstruction(Arena& arena, const IRInstruction* inst, Id id) : m_op(inst->m_op) , m_typeParam(inst->m_typeParam) , m_numSrcs(inst->m_numSrcs) , m_numDsts(inst->m_numDsts) , m_id(id) , m_srcs(m_numSrcs ? new (arena) SSATmp*[m_numSrcs] : nullptr) , m_dst(nullptr) , m_marker(inst->m_marker) , m_extra(inst->m_extra ? cloneExtra(op(), inst->m_extra, arena) : nullptr) { std::copy(inst->m_srcs, inst->m_srcs + inst->m_numSrcs, m_srcs); setTaken(inst->taken()); }
GLvoid CBlock::claimBlock(GLubyte owner) { this->owner = owner; setType(CV_BLOCK_TYPE_CLAIMED_LAND_ID); setTaken(false); //init and finalize surrounding blocks aswell as this one CV_GAME_MANAGER->getLevelManager()->getBlock(logicalPosition[0],logicalPosition[1]-1)->init(); CV_GAME_MANAGER->getLevelManager()->getBlock(logicalPosition[0]-1,logicalPosition[1])->init(); CV_GAME_MANAGER->getLevelManager()->getBlock(logicalPosition[0]+1,logicalPosition[1])->init(); CV_GAME_MANAGER->getLevelManager()->getBlock(logicalPosition[0],logicalPosition[1]+1)->init(); init(); CV_GAME_MANAGER->getLevelManager()->getBlock(logicalPosition[0],logicalPosition[1]-1)->finalize(); CV_GAME_MANAGER->getLevelManager()->getBlock(logicalPosition[0]-1,logicalPosition[1])->finalize(); CV_GAME_MANAGER->getLevelManager()->getBlock(logicalPosition[0]+1,logicalPosition[1])->finalize(); CV_GAME_MANAGER->getLevelManager()->getBlock(logicalPosition[0],logicalPosition[1]+1)->finalize(); finalize(); // Add to unfortified list. if(CV_GAME_MANAGER->getLevelManager()->getBlock(logicalPosition[0],logicalPosition[1]-1)->type == CV_BLOCK_TYPE_EARTH_ID) CV_GAME_MANAGER->getLevelManager()->addUnfortifiedBlock(CV_GAME_MANAGER->getLevelManager()->getBlock(logicalPosition[0],logicalPosition[1]-1)); if(CV_GAME_MANAGER->getLevelManager()->getBlock(logicalPosition[0]-1,logicalPosition[1])->type == CV_BLOCK_TYPE_EARTH_ID) CV_GAME_MANAGER->getLevelManager()->addUnfortifiedBlock(CV_GAME_MANAGER->getLevelManager()->getBlock(logicalPosition[0]-1,logicalPosition[1])); if(CV_GAME_MANAGER->getLevelManager()->getBlock(logicalPosition[0]+1,logicalPosition[1])->type == CV_BLOCK_TYPE_EARTH_ID) CV_GAME_MANAGER->getLevelManager()->addUnfortifiedBlock(CV_GAME_MANAGER->getLevelManager()->getBlock(logicalPosition[0]+1,logicalPosition[1])); if(CV_GAME_MANAGER->getLevelManager()->getBlock(logicalPosition[0],logicalPosition[1]+1)->type == CV_BLOCK_TYPE_EARTH_ID) CV_GAME_MANAGER->getLevelManager()->addUnfortifiedBlock(CV_GAME_MANAGER->getLevelManager()->getBlock(logicalPosition[0],logicalPosition[1]+1)); if(CV_GAME_MANAGER->getControlManager()->getViewFrustum()->containsBBOX(getBoundingBox())) { //since the block is visible, create the claim effect CBlockObject *obj = new CBlockObject("MODEL_KEY",this->getRealPosition()+vector3f(CV_BLOCK_WIDTH/2.0f,CV_BLOCK_HEIGHT/4.0f,CV_BLOCK_DEPTH/2.0f), NULL); obj->setEffectName("EFFECTS_CLAIM"); obj->setEffect(CV_GAME_MANAGER->getResourceManager()->getEffect("EFFECTS_CLAIM")); if(obj->getEffect()) obj->getEffect()->getEmittter(0)->setColor(vector3f(1.0f,0.2f,0.6f)); this->addModel(obj); } }
void IRInstruction::become(IRUnit& unit, IRInstruction* other) { assert(other->isTransient() || m_numDsts == other->m_numDsts); auto& arena = unit.arena(); // Copy all but m_id, m_edges[].from, m_listNode, m_marker, and don't clone // dests---the whole point of become() is things still point to us. if (hasEdges() && !other->hasEdges()) { clearEdges(); } else if (!hasEdges() && other->hasEdges()) { m_edges = new (arena) Edge[2]; setNext(other->next()); setTaken(other->taken()); } m_op = other->m_op; m_typeParam = other->m_typeParam; m_numSrcs = other->m_numSrcs; m_extra = other->m_extra ? cloneExtra(m_op, other->m_extra, arena) : nullptr; m_srcs = new (arena) SSATmp*[m_numSrcs]; std::copy(other->m_srcs, other->m_srcs + m_numSrcs, m_srcs); }
void IRInstruction::convertToJmp(Block* target) { convertToJmp(); setTaken(target); }
void AgroShield::SDI12(uint8_t mode) { switch( mode ) { case CHECK_ALL : mySDI12.begin(); delay(500); // Tempo para que mySDI12 seja iniciado. /* Efectua um Scan rápido de todos os endereços. */ Serial.println(" | SEARCH FOR SENSORS"); Serial.println(" | Scanning all addresses, please wait..."); for(byte i = '0'; i <= '9'; i++) if(checkActive(i)) setTaken(i); // Scan dos endereços entre 0-9 for(byte i = 'a'; i <= 'z'; i++) if(checkActive(i)) setTaken(i); // Scan dos endereços entre a-z for(byte i = 'A'; i <= 'Z'; i++) if(checkActive(i)) setTaken(i); // Scan dos endereços entre A-Z /* Imprime a informação actual de cada sensor activo. */ // Scan dos endereços entre 0-9 for(char i = '0'; i <= '9'; i++) if(isTaken(i)){ Serial.println(""); getDateTime(); found_check_all = true; Serial.print("Sensor "); Serial.print(i); Serial.print(":"); printInfo(i); //Serial.println(); } // Scan dos endereços entre a-z for(char i = 'a'; i <= 'z'; i++) if(isTaken(i)){ Serial.println(""); getDateTime(); found_check_all = true; Serial.print("Sensor "); Serial.print(i); Serial.print(": "); printInfo(i); //Serial.println(); } // Scan dos endereços entre A-Z for(char i = 'A'; i <= 'Z'; i++) if(isTaken(i)){ Serial.println(""); getDateTime(); found_check_all = true; Serial.print("Sensor "); Serial.print(i); Serial.print(":"); printInfo(i); //Serial.println(); }; if(!found_check_all) { Serial.println(" | No sensors found, please check connections and restart the Arduino.\n"); //while(true); //break; } // stop here mySDI12.end(); delay(500); found_check_all = false; break; case WILD_CARD : mySDI12.begin(); delay(500); // Tempo para que mySDI12 seja iniciado. mySDI12.sendCommand(wild_card_Command); delay(300); // Espera um tempo pela resposta. Serial.println(" | SENSORS CONNECTED"); getDateTime(); while(mySDI12.available()){ // Escreve a resposta no Serial Monitor. Serial.write(mySDI12.read()); //Serial.print(" | "); } Serial.println(""); mySDI12.end(); delay(500); break; case SIMPLE_LOGGER : mySDI12.begin(); delay(500); // Tempo para que mySDI12 seja iniciado. ////////////////////////////////////////////// Serial.println(); Serial.println(" | SENSORS INFORMATION AND MEASUREMENTS "); Serial.println(" | Scanning all addresses, please wait..."); /* Efectua um Scan rápido de todos os endereços. */ for(byte i = '0'; i <= '9'; i++) if(checkActive(i)) setTaken(i); // Scan dos endereços entre 0-9 for(byte i = 'a'; i <= 'z'; i++) if(checkActive(i)) setTaken(i); // Scan dos endereços entre a-z for(byte i = 'A'; i <= 'Z'; i++) if(checkActive(i)) setTaken(i); // Scan dos endereços entre A-Z /* Verificar se existem sensores activos. */ // for(byte i = 0; i < 62; i++){ // if(isTaken(i)){ // found = true; // break; // } // } for(char i = '0'; i <= '9'; i++){ if(isTaken(i)){ found = true; //Serial.print("Checking address "); //Serial.print(i); //Serial.print("..."); break; } } for(char i = 'a'; i <= 'z'; i++){ if(isTaken(i)){ found = true; //Serial.print("Checking address "); //Serial.print(i); //Serial.print("..."); break; } } for(char i = 'A'; i <= 'Z'; i++){ if(isTaken(i)){ found = true; //Serial.print("Checking address "); //Serial.print(i); //Serial.print("..."); break; } } if(!found) { Serial.println(" | No sensors found, please check connections and restart the Arduino.\n"); //while(true); break; } // stop here Serial.println(); Serial.println(" | Time Elapsed (s), Sensor Address and ID"); Serial.println(" | Sensor Address, Measurement 1, Measurement 2, ... etc."); Serial.println(" | -------------------------------------------------------------------------------"); ////////////////////////////////////////////// // Scan dos endereços entre 0-9 for(char i = '0'; i <= '9'; i++) if(isTaken(i)){ getDateTime(); Serial.print(millis()/1000); Serial.print(","); printInfo(i); //getDateTime(); takeMeasurement(i); Serial.println(""); } // Scan dos endereços entre a-z for(char i = 'a'; i <= 'z'; i++) if(isTaken(i)){ getDateTime(); Serial.print(millis()/1000); Serial.print(","); printInfo(i); //getDateTime(); takeMeasurement(i); Serial.println(""); } // Scan dos endereços entre A-Z for(char i = 'A'; i <= 'Z'; i++) if(isTaken(i)){ getDateTime(); Serial.print(millis()/1000); Serial.print(","); printInfo(i); //getDateTime(); takeMeasurement(i); Serial.println(""); }; ////////////////////////////////////////////// mySDI12.end(); delay(500); break; case INTERFACE : mySDI12.begin(); delay(500); // Tempo para que mySDI12 seja iniciado. mySDI12.sendCommand(""); Serial.println(" | INTERFACE COM SENSORES SDI-12"); Serial.println(" | Insira o comando a enviar (''exit'' para sair)..."); Serial.println(""); while(estado){ if(Serial.available() > 0) { myCommand = Serial.readStringUntil('\n'); //x = Serial.parseInt(); if (myCommand == "exit") { Serial.println(" | Saiu do envio de comandos"); Serial.println(""); estado = false; } if (estado){ //if ( (myCommand[0] >= '0' && myCommand[0] <= '9' || myCommand[0] >= 'a' && myCommand[0] <= 'z' || //myCommand[0] >= 'A' && myCommand[0] <= 'Z' || myCommand[0] == '?') && (myCommand[1] == 'I' || //myCommand[1] == 'M' || myCommand[1] == 'D' || myCommand[1] == 'A') && (myCommand[2] == '!' || //(myCommand[3] == '!' && (myCommand[2] >= '0' && myCommand[2] <= '9' || myCommand[2] >= 'a' && //myCommand[2] <= 'z' || myCommand[2] >= 'A' && myCommand[2] <= 'Z')) ) ) if ( (myCommand[0] >= '0' && myCommand[0] <= '9' || myCommand[0] >= 'a' && myCommand[0] <= 'z' || myCommand[0] >= 'A' && myCommand[0] <= 'Z' || myCommand[0] == '?') && (myCommand[1] == '!' || myCommand[1] == 'I' || myCommand[1] == 'M' || myCommand[1] == 'D' || myCommand[1] == 'A') && (myCommand[1] == '!' || myCommand[2] == '!' || (myCommand[3] == '!' && (myCommand[2] >= '0' && myCommand[2] <= '9' || myCommand[2] >= 'a' && myCommand[2] <= 'z' || myCommand[2] >= 'A' && myCommand[2] <= 'Z')) ) ) { getDateTime(); Serial.println(myCommand); for(int j = 0; j < 1; j++){ mySDI12.sendCommand(myCommand); // mySDI12.flush(); delay(300); if(mySDI12.available()>1) break; if(mySDI12.available()) mySDI12.read(); } delay(300); //mySDI12.read(); //consume sensor address (you can keep it if you'd like) if(mySDI12.available()){ getDateTime(); } // while(mySDI12.available()){ // comandorecebido = (String)mySDI12.read(); // if(comandorecebido == "\n"){ // Serial.println(" | "); // Serial.println(comandorecebido); // } // Serial.println(comandorecebido); // delay(5); // } while(mySDI12.available()){ Serial.write(mySDI12.read()); delay(5); } Serial.println(""); } else{ Serial.println(" | Comando Invalido"); Serial.println(""); } } } } // if(!estado) // while(!estado){ // if(Serial.available() > 0) // { // myCommand = Serial.readStringUntil('\n'); // //if (myCommand == "run sdi monitor") // if (myCommand == "run") // { // estado = true; // Serial.println("Entrou do envio de comandos"); // } // } // } mySDI12.end(); delay(500); estado = true; break; default : ; } }
void NetworkConnection::setTaken(SOCKET conn) { connection = conn; setTaken(); }