Exemplo n.º 1
0
int moveCardOntoAnother(card_t *card, card_t *onto) {
  cardstack_t *dest = onto->stack;
  printf("onto LAIN %d %d\n", dest->type == LAIN, dest->type);
  printf("card LAIN %d %d\n", card->stack->type == LAIN, card->stack->type);
  printf("isUp %d\n",isUp(card));
  printf("isOnTop %d\n",isOnTop(onto));
  printf("isOkOn %d\n",isOkOn(card,onto));
  if ((dest->type == LAIN) && isUp(card) && isOnTop(onto) && isOkOn(card,onto)) {
    move_onto(card,dest);
    return SUCCESS;
  } else {
    return FAILURE;
  }
}
Exemplo n.º 2
0
void setDisplay(){
  if (modechanged){
    gotoXY(0,0);
    sprintf(cha, " Ustaw. wysw.");LcdString(cha, true);
    gotoXY(0,1);
    sprintf(cha, EMPTY_LINE);LcdString(cha, false);
  }
  gotoXY(0,1);
  sprintf(cha, "kontrast:");LcdString(cha,false);
  gotoXY(60,1);
  sprintf(cha, "%02i", contrast_val);LcdString(cha, (pos_setDisp==0));
  gotoXY(0,2);
  sprintf(cha, "jasnosc:");LcdString(cha,false);
  gotoXY(60,2);
  sprintf(cha, "%02i", jasnosc_val);LcdString(cha, (pos_setDisp==1));
  gotoXY(0,3);
  sprintf(cha, "OK");LcdString(cha,(pos_setDisp==2));  
  if (modechanged){
    gotoXY(0,4);
    sprintf(cha, "<> poprz/nast");LcdString(cha);
    gotoXY(0,5);
    sprintf(cha, "^v wart +/-");LcdString(cha);

    modechanged=false;
  }
  
  if (pos_setDisp==0){
    if (isUp())  { contrast_val=obetnij(contrast_val+1, 10, true); LcdInitialise(); }
    if (isDown()) { contrast_val=obetnij(contrast_val-1, 10, true); LcdInitialise(); }
  }
  else if (pos_setDisp==1){
    if (isUp())   { jasnosc_val=obetnij(jasnosc_val+1, 50); analogWrite(11, jasnosc_val); }
    if (isDown()) { jasnosc_val=obetnij(jasnosc_val-1, 50); analogWrite(11, jasnosc_val); }
  }
  if (pos_setDisp==2){
    if (isPressed()) {
      mode=1;
      modechanged=true;
      LcdClear();
      return;
    }
  }
  
  if (isRight())  pos_setDisp++;
  if (isLeft()) pos_setDisp--;
  if (pos_setDisp>2) pos_setDisp=0;
  if (pos_setDisp<0) pos_setDisp=2;
}
Exemplo n.º 3
0
void 
PPPStats::timerEvent( QTimerEvent * )
{
  if (!isUp()) return;
  
  DclPPPInfo        PPPInfo[1];
  struct ifreq      ifreq;

  memset( &ifreq, 0, sizeof(ifreq) );
  sprintf( ifreq.ifr_ifrn.ifrn_name, "ppp%d", pppDev );

  ifreq.ifr_ifru.ifru_data = (caddr_t) PPPInfo;

  if (ioctl (soc, SIOCGPPPSTATS, (caddr_t) & ifreq) == 0)
  {
    unsigned rxDelta = PPPInfo->stats.p.ppp_ibytes - rxTotal;
    unsigned txDelta = PPPInfo->stats.p.ppp_obytes - txTotal;
    
    rxTotal = PPPInfo->stats.p.ppp_ibytes;
    txTotal = PPPInfo->stats.p.ppp_obytes;
    
    if (rxDelta == rxTotal) rxDelta = 0;
    if (txDelta == txTotal) txDelta = 0;
    
    emit status( rxDelta, txDelta, rxTotal, txTotal );
  }
}
Exemplo n.º 4
0
 /** Shut down the current session together with all associated services.
  *  @todo avoid blocking when aborting render processes ///////////// TICKET #201
  *  @todo well defined transactional behaviour  ///////////////////// TICKET #698
  * @warning throws error::Fatal or even deadlocks when called from session thread
  */
 void
 SessManagerImpl::close()
 {
   Lock sync(this);
   if (isUp())
     lifecycle_->shutDown();
   pSess_.reset();
 }
Exemplo n.º 5
0
void devEthernet::dumpBasicInfo() {
	ACE_TRACE("devEthernet::dumpBasicInfo");
	if ( isNew() ) { return; }

	ND_DEBUG("Iface name: %s, Index: %d, Up: %s, MAC: %s, Protected: %s\n",
		getIfaceName().c_str(), index(), isUp()? "true" : "false", getMacStr().c_str(),
		isProtected()? "true" : "false" );
}
Exemplo n.º 6
0
 /** @todo error handling, how to deal with a partially configured session?
  *  @todo for \c reset() to work, we need to change the implementation of
  *        AssetManager so support this kind of transactional switch!
  * @warning throws error::Fatal or even deadlocks when called from session thread
  */
 void
 SessManagerImpl::reset()
 {
   Lock sync(this);
   if (isUp())
     lifecycle_->shutDown();
   lifecycle_->pullUp();
 }
Exemplo n.º 7
0
int moveKingOntoFree(card_t *king, deal_t *deal) {
  cardstack_t *dest = findEmptyLainStack(deal);
  if (isUp(king) && dest != NULL) {
    move_onto(king,dest);
    return SUCCESS;
  } else {
    return FAILURE;
  }
}
Exemplo n.º 8
0
 /**
  * @warning throws error::Fatal or even deadlocks when called from session thread
  */
 void
 SessManagerImpl::load()
 {
   UNIMPLEMENTED ("load serialised session");
   Lock sync(this);
   if (isUp())
     lifecycle_->shutDown();
   lifecycle_->pullUp();
 }
Exemplo n.º 9
0
    Dir step(Dir dir)
    {
        p.x = (p.x << 1) | (isEast(dir)  ? 1u : 0u);
        p.y = (p.y << 1) | (isNorth(dir) ? 1u : 0u);
        p.z = (p.z << 1) | (isUp(dir)    ? 1u : 0u);

        b.go(dir);
        return dir;
    }
Exemplo n.º 10
0
int moveCardOntoAnother(card_t *card, card_t *onto) {
  cardstack_t *dest = onto->stack;
  if ((dest->type == LAIN) && isUp(card) && isOnTop(onto) && isOkOn(card,onto)) {
    move_onto(card,dest);
    return SUCCESS;
  } else {
    return FAILURE;
  }
}
Exemplo n.º 11
0
int main(){

char ch;

scanf("%c",&ch);

printf("\n%d\n",isUp(ch));

return 0;
}
bool Interface::write(Packet& p_Frame)
{
	if(isUp())
	{
		m_ForwardingBuffer.write(p_Frame);
		return true;
	}
	else
		return false;

}
Exemplo n.º 13
0
/*!
  This function is only called by \l QGraphicsScene::advance().

  The shield's position is always computed from the ship's
  position, so the shield is not moved here. Neither is the
  shield destroyed here, because the shield is meant to
  exist for as long as the ship exists. The only thing that
  happens here is that in \a phase 1 the shield is either
  shown or hidden depending on whether it is marked as
  being up or not.

  The shield is created when the ship is created. The shield
  is deleted when the ship is deleted.

  \internal
 */
void KShield::advance(int phase)
{
    if ((phase == 0) && dying())
	markDead();
    else if (phase == 1) {
	if (isDead() || dying()) {
	    delete this;
	    return;
	}
	if (isUp())
	    show();
	else
	    hide();
    }
}
Exemplo n.º 14
0
    void ExplorerWidget::ui_itemDoubleClicked(QTreeWidgetItem *item, int column)
    {
        auto collectionItem = dynamic_cast<ExplorerCollectionTreeItem *>(item);
        if (collectionItem) {
            AppRegistry::instance().app()->openShell(collectionItem->collection());
            return;
        }

        auto replicaMemberItem = dynamic_cast<ExplorerReplicaSetTreeItem*>(item);
        if (replicaMemberItem && replicaMemberItem->isUp()) {
            AppRegistry::instance().app()->openShell(replicaMemberItem->server(), 
                replicaMemberItem->connectionSettings(), ScriptInfo("", true));
            return;
        }

        // Toggle expanded state
        item->setExpanded(!item->isExpanded());
    }
Exemplo n.º 15
0
void showMenu(){
  if (isPressed()) {
    mode=pos_menu+2;
    modechanged=true;
    if (mode==5) mode=0; 
    LcdClear();
    return;  
  }

  gotoXY(0,0);
  sprintf(cha, " Menu glowne ");LcdString(cha, true);
  gotoXY(0,1);
  sprintf(cha, "    "); LcdString(cha, false);
  gotoXY(20,1);
  sprintf(cha, "budzik"); LcdString(cha, (pos_menu==0));
  gotoXY(0,2);
  sprintf(cha, "ust."); LcdString(cha, (pos_menu==1));
  gotoXY(30,2);
  sprintf(cha, " ^  "); LcdString(cha, false);
  gotoXY(50,2);
  sprintf(cha, "ust."); LcdString(cha, (pos_menu==2));
  gotoXY(0,3);
  sprintf(cha, "czas"); LcdString(cha, (pos_menu==1));
  gotoXY(30,3);
  sprintf(cha, "< > "); LcdString(cha, false);
  gotoXY(50,3);
  sprintf(cha, "wysw"); LcdString(cha, (pos_menu==2));
  gotoXY(0,4);
  sprintf(cha, "     v"); LcdString(cha, false);
  gotoXY(0,5);
  sprintf(cha, "    "); LcdString(cha, false);
  gotoXY(20,5);
  sprintf(cha, "powrot"); LcdString(cha, (pos_menu==3));
  
  if (isUp()) pos_menu=0;
  if (isDown()) pos_menu=3;
  if (isRight()) pos_menu=2;
  if (isLeft()) pos_menu=1;
}
Exemplo n.º 16
0
void BcmPort::setSpeed(const shared_ptr<Port>& swPort) {
  int ret;
  cfg::PortSpeed desiredPortSpeed;
  if (swPort->getSpeed() == cfg::PortSpeed::DEFAULT) {
    int speed;
    ret = opennsl_port_speed_max(unit_, port_, &speed);
    bcmCheckError(ret, "failed to get max speed for port", swPort->getID());
    desiredPortSpeed = cfg::PortSpeed(speed);
  } else {
    desiredPortSpeed = swPort->getSpeed();
  }

  int desiredSpeed = static_cast<int>(desiredPortSpeed);
  // Unnecessarily updating BCM port speed actually causes
  // the port to flap, even if this should be a noop, so check current
  // speed before making speed related changes. Doing so fixes
  // the interface flaps we were seeing during warm boots

  int curSpeed = static_cast<int>(getSpeed());

  // If the port is down or disabled its safe to update mode and speed to
  // desired values
  bool portUp = isUp();

  // Update to correct mode and speed settings if the port is down/disabled
  // or if the speed changed. Ideally we would like to always update to the
  // desired mode and speed. However these changes are disruptive, in that
  // they cause a port flap. So to avoid that, we don't update to desired
  // mode if the port is UP and running at the desired speed. Speed changes
  // though are applied to UP ports as well, since running at wrong (lower than
  // desired) speed is pretty dangerous, and can trigger non obvious outages.
  //
  // Another practical reason for not updating to the desired mode on ports that
  // are UP is that there is at least one bug whereby SDK thinks that the ports
  // are in a different mode than they actually are. We are tracking that
  // separately. Once that is resolved, we can do a audit to see that if all
  // ports are in desired mode settings, we can make mode changes a first
  // class citizen as well.
  if (!portUp || curSpeed != desiredSpeed) {
    opennsl_port_if_t desiredMode = getDesiredInterfaceMode(desiredPortSpeed,
                                                        swPort->getID(),
                                                        swPort->getName());

    // Check whether we have the correct interface set
    opennsl_port_if_t curMode;
    ret = opennsl_port_interface_get(unit_, port_, &curMode);
    bcmCheckError(ret,
                  "Failed to get current interface setting for port ",
                  swPort->getID());

    if (curMode != desiredMode) {
      // Changes to the interface setting only seem to take effect on the next
      // call to opennsl_port_speed_set()
      ret = opennsl_port_interface_set(unit_, port_, desiredMode);
      bcmCheckError(
          ret, "failed to set interface type for port ", swPort->getID());
    }

    if (portUp) {
      // Changing the port speed causes traffic disruptions, but not doing
      // it would cause inconsistency.  Warn the user.
      LOG(WARNING) << "Changing port speed on up port. This will "
                   << "disrupt traffic. Port: " << swPort->getName()
                   << " id: " << swPort->getID();
    }

    // Note that we call speed_set even if the speed is already set
    // properly and port is down. This is because speed_set
    // reinitializes the MAC layer of the port and allows us to pick
    // up changes in interface mode and finalize flex port
    // transitions. We ensure that the port is down for these
    // potentially unnecessary calls, as otherwise this will cause
    // port flaps on ports where link is up.
    ret = opennsl_port_speed_set(unit_, port_, desiredSpeed);
    bcmCheckError(
      ret,
      "failed to set speed to ",
      desiredSpeed,
      " from ",
      curSpeed,
      ", on port ",
      swPort->getID());
    getPlatformPort()->linkSpeedChanged(desiredPortSpeed);
  }
}
Exemplo n.º 17
0
 bool Keyboard::isReleased(SDL_Scancode key) const
 {
     return isUp(key) && state_[key].second == tick_;
 }
Exemplo n.º 18
0
void Input::GameInput::update(const sf::Event& ite)
{
	 /*if(!locked && isJoystickEvent(ite.type) && mode == MouseKeyboard)
	 {
	 	mode = Joystick;
	 }
	 else if(!locked && isMouseKeyboardEvent(ite.type) && mode == Joystick)
	 {
	 	mode = MouseKeyboard;
	 }*/

	 if (ite.type == sf::Event::KeyPressed)
	 {
		 clavier[ite.key.code] = true;
	 }

		 else if (ite.type == sf::Event::KeyReleased)
		 {
			 clavier[ite.key.code] = false;
		 }

		 else if (ite.type == sf::Event::MouseButtonPressed)
		 {
			 souris[(const char)ite.mouseButton.button] = true;
			 relX = posX - ite.mouseButton.x;
			 relY = posY - ite.mouseButton.y;
			 posX = ite.mouseButton.x;
			 posY = ite.mouseButton.y;
		 }

		 else if (ite.type == sf::Event::MouseButtonReleased)
		 {
			 souris[(const char)ite.mouseButton.button] = false;
		 }

		 else if (ite.type == sf::Event::JoystickButtonPressed)
		 {
			 joyButtons[ite.joystickButton.button] = true;
		 }

		 else if(ite.type == sf::Event::JoystickButtonPressed)
		 {
			 joyButtons[ite.joystickButton.button] = false;
		 }

		 else if (ite.type == sf::Event::JoystickMoved)
		 {
			 leftJoy = false;
			 downJoy = false;
			 rightJoy = false;
			 upJoy = false;
			
			 if (ite.joystickMove.axis == sf::Joystick::X)/*(joyInput.GetJoystickAxis(0, sf::Joystick::X) < -25)*/
			 {
					leftJoy = true;
			 }
			 /*else if (joyInput.GetJoystickAxis(0, sf::Joystick::X)  > 25)
			 {
					rightJoy = true;
			 }*/
			 if (ite.joystickMove.axis == sf::Joystick::Y)/*(joyInput.GetJoystickAxis(0, sf::Joystick::Y)  > 25)*/
			 {
				 upJoy = true;
			 }
			/* else if(joyInput.GetJoystickAxis(0, sf::Joystick::Y)  < -25)
			 {
				downJoy = true;
			 }*/

				
		 }
		 if(isUp())
		 	Notify(Events::Move(),std::make_pair(0,-1));
		 if(isDown())
		 	Notify(Events::Move(),std::make_pair(0,1));
		 if(isRight())
		 	Notify(Events::Move(),std::make_pair(1,0));
		 if(isLeft())
		 	Notify(Events::Move(),std::make_pair(-1,0));
		 if(isShoot())
		 	Notify(Events::Shoot());
		 if(isQuit())
		 	Notify(Events::Quit());
}
Exemplo n.º 19
0
void displayClock(){
  PAR = not PAR;
  
  char* clock = rtc.formatTime(); int p=-14/*+7*/;
  LcdCharacterBig(p+=14,0,clock[0],false);
  LcdCharacterBig(p+=14,0,clock[1],false);
  LcdCharacterBig(p+=14,0,'-',false);
  LcdCharacterBig(p+=14,0,clock[3],false);
  LcdCharacterBig(p+=14,0,clock[4],false);
  
  gotoXY(70,2); sprintf (cha, "%02i", rtc.getSecond());LcdString(cha,true);
  
  gotoXY(0,4);
  sprintf (cha, "%02i/%02i/2016", rtc.getDay(), rtc.getMonth());LcdString(cha);

  gotoXY(0,5);
  sprintf (cha, "%02i'C | %02i%%", (int)(dht.readTemperature()), (int)(dht.readHumidity()));LcdString(cha);
  
  if (alarmENABLED){
   sprintf(cha, "#");
   gotoXY(77,4); LcdString(cha,true); 
   gotoXY(77,5); LcdString(cha,true);  
  }
  else{
   sprintf(cha, " ");
   gotoXY(77,4); LcdString(cha,false); 
   gotoXY(77,5); LcdString(cha,false);  
  }
  
  if (alarmACTIVE){
    sprintf(cha, "   budzik   ");
    gotoXY(0,3);LcdString(cha, PAR);
  }
  else if (alarmSNOOZE){
    sprintf(cha, "   drzemka  ");
    gotoXY(0,3);LcdString(cha, PAR);
  }
  else{
    sprintf(cha, EMPTY_LINE);
    gotoXY(0,3);LcdString(cha);
  }

  if (alarmINT){
    if(b){
      alarmCOMPLETED=true;
      alarmACTIVE=false;
      alarmINT=false;
      alarmSNOOZE=true;
      alarmTmp.addMinutes(SNOOZE_TIME);
    }
  }
  else{
    if (b){mode=1;modechanged=true;LcdClear();return;}
    if (isRight()&&isUp()){
      enableAlarm();
    }
  }
  if (isLeft()&&isDown()){
    if (alarmACTIVE) alarmCOMPLETED=true;
    else disableAlarm();
    alarmSNOOZE=false;
    alarmTmp=alarm;
    alarmINT=false;
    alarmACTIVE=false;
    alarmENABLED=false;
  }
}
Exemplo n.º 20
0
void setClock(bool isClock){
  char hh[3];
  if (isClock)
    sprintf(hh, "%02i", rtc.getHour());
  else
    sprintf(hh, "%02i", alarm.h);
  char mm[3];
  if (isClock)
    sprintf(mm, "%02i", rtc.getMinute());
  else
    sprintf(mm, "%02i", alarm.m);
  char day[3]; char month[3];
  if (isClock){
    sprintf(day,   "%02i", rtc.getDay());
    sprintf(month, "%02i", rtc.getMonth());   
  }

  if (modechanged){
    if (isClock){ sprintf(cha, " Ustaw czas ");}
    else        { sprintf(cha, "Ustaw budzik");}
    gotoXY(0,0);
    LcdString(cha, true);
    gotoXY(0,1);
    sprintf(cha, EMPTY_LINE);LcdString(cha, false);
  }
  
  gotoXY(0,1);
  LcdString(hh,(pos_setClock==0));
  gotoXY(15,1);
  sprintf(cha, ":"); LcdString(cha, false);
  gotoXY(20,1);
  LcdString(mm,(pos_setClock==1));
  gotoXY(70,1);
  sprintf(cha, "OK");LcdString(cha,(pos_setClock==2));  

  if (isClock){
    gotoXY(0,2);
    LcdString(day,(pos_setClock==3));
    gotoXY(15,2);
    sprintf(cha, "/"); LcdString(cha, false);
    gotoXY(20,2);
    LcdString(month,(pos_setClock==4));
    gotoXY(35,2);
    sprintf(cha, "/2016");LcdString(cha);  
  }

  if (modechanged){
    gotoXY(0,3);
    sprintf(cha, EMPTY_LINE);LcdString(cha, false);
    gotoXY(0,4);
    sprintf(cha, "<> poprz/nast");LcdString(cha);
    gotoXY(0,5);
    sprintf(cha, "^v wart +/-");LcdString(cha);
    
    modechanged=false;
  }
  
  if (isClock){
    if (pos_setClock==0){
      if (isUp())   rtc.setTime(obetnij(rtc.getHour()+1, 23), rtc.getMinute(), rtc.getSecond());
      if (isDown()) rtc.setTime(obetnij(rtc.getHour()-1, 23), rtc.getMinute(), rtc.getSecond());
    }
    if (pos_setClock==1){
      if (isUp())   rtc.setTime(rtc.getHour(), obetnij(rtc.getMinute()+1,59), rtc.getSecond());
      if (isDown()) rtc.setTime(rtc.getHour(), obetnij(rtc.getMinute()-1,59), rtc.getSecond());   
    }
    if (pos_setClock==3){
      if (isUp())   rtc.setDate(obetnij(rtc.getDay()+1,31), 1, rtc.getMonth(), 21, 16);
      if (isDown()) rtc.setDate(obetnij(rtc.getDay()-1,31), 1, rtc.getMonth(), 21, 16);
    }
    if (pos_setClock==4){
      if (isUp())   rtc.setDate(rtc.getDay(), 1, obetnij(rtc.getMonth()+1,12), 21, 16);   
      if (isDown()) rtc.setDate(rtc.getDay(), 1, obetnij(rtc.getMonth()-1,12), 21, 16);   
    }
  }
  else{
    if (pos_setClock==0){
      if (isUp())   alarm.h = obetnij(alarm.h+1, 23);
      if (isDown()) alarm.h = obetnij(alarm.h-1, 23);
    }
    if (pos_setClock==1){
      if (isUp())   alarm.m = obetnij(alarm.m+1,59);
      if (isDown()) alarm.m = obetnij(alarm.m-1,59);
    }    
  }
  
  if (pos_setClock==2){
    if (isPressed()) {
      mode=1;
      modechanged=true;
      LcdClear();
      return;
    }
  }

  alarmTmp = alarm;
  
  if (isRight())  pos_setClock++;
  if (isLeft())   pos_setClock--;
  if (isClock){
    if (pos_setClock>4) pos_setClock=0;
    if (pos_setClock<0) pos_setClock=4;
  }
  else {
    if (pos_setClock>2) pos_setClock=0;
    if (pos_setClock<0) pos_setClock=2;
  }
}
Exemplo n.º 21
0
inline bool isDown(Dir dir) { return !isUp(dir); }
void JoystickShield::processCallbacks() {
    processEvents();

    // Joystick Callbacks
    if (isCenter() && centerCallback != NULL) {
        centerCallback();
    }

    if (isUp() && upCallback != NULL) {
        upCallback();
    }

    if (isRightUp() && rightUpCallback != NULL) {
        rightUpCallback();
    }

    if (isRight() && rightCallback != NULL) {
        rightCallback();
    }

    if (isRightDown() && rightDownCallback != NULL) {
        rightDownCallback();
    }

    if (isDown() && downCallback != NULL) {
        downCallback();
    }

    if (isLeftDown() && leftDownCallback != NULL) {
        leftDownCallback();
    }

    if (isLeft() && leftCallback != NULL) {
        leftCallback();
    }

    if (isLeftUp() && leftUpCallback != NULL) {
        leftUpCallback();
    }

    // Button Callbacks
    if (isJoystickButton() && jsButtonCallback != NULL) {
        jsButtonCallback();
    }

    if (isUpButton() && upButtonCallback != NULL) {
        upButtonCallback();
    }

    if (isRightButton() && rightButtonCallback != NULL) {
        rightButtonCallback();
    }

    if (isDownButton() && downButtonCallback != NULL) {
        downButtonCallback();
    }

    if (isLeftButton() && leftButtonCallback != NULL) {
        leftButtonCallback();
    }

}