Пример #1
0
State_t NetworkRun::detectState( void ) {
    InterfaceInfo * II = networkSetup()->assignedInterface();

    if( II && II->IsUp ) {
      // device has assigned interface
      return IsUp;
    }

    // had no interface or interface is no longer up -> release
    networkSetup()->assignInterface( 0 );

    return Unknown;
}
Пример #2
0
bool Game::setup(){

	mOgreRoot = new Ogre::Root(mOgrePluginsCfg);

	setupResources();

	chooseSceneManager();

	if(!configure())
		return false;

	// Create any resource listeners (for loading screens)
	createResourceListener();
	// Load resources
	loadResources();

	// Create the frame listener
	createFrameListener();

	bulletSetup();

	if(mOnlineMode)
		networkSetup();
	else
		offlineSetup();

	if(mInput->hasOculusRift())
		mGameWindow->setViewMode(OCULUS);
	else
		mGameWindow->setViewMode(SIMPLE);

	return true;

}
Пример #3
0
QString NetworkRun::setMyState( NetworkSetup * NC, Action_t A, bool ) {
    // we handle UP and DOWN
    InterfaceInfo * II = NC->assignedInterface();

    if( ! II ) {
      Log(( "no interface assigned." ));
      return QString();
    }

    QStringList SL;

    if( A == Up ) {
      // we can bring UP if lower level is available
      SL << "ifup";
    } else if( A == Down ) {
      SL << "ifdown";
    } else {
      return QString();
    }

    SL << QString().sprintf( "%s=A%ld%s",
                        II->Name.latin1(),
                        networkSetup()->number(),
                        II->Name.latin1() );

    if( ! NSResources->system().runAsRoot( SL ) ) {
      return QString("Cannot call %1").arg(SL.join(" "));
    }

    return QString();
}
Пример #4
0
/**
 *  @brief Main.
 *
 *    This function starts everything.
 *    It initialises the Network and Keypad.
 *    If either of these fail then the program exits with an error.
 *
 *    If not, then threads are initialised and the
 *    function 'closing_time' is associated with a signal to exit.
 *    This allows the threads of be killed safely and the
 *    7 segment display to be cleared.
 *
 *    After initialisation, the user is asked to toggle the
 *    emergency state with the letter 'e', or to e'x'it the program.
 *
 *  @param Void.
 *  @return Void.
 */
int main (void) {
  int ret;
  int prev_state = state;
//  sighandler_t

  if(ret = networkSetup() != 0){
    printd("Socket failed to init, error no: %d\n", ret);
    printf("Network setup failed\n");
    return 1;
  }

  printd("Setting up USB ACM terminal\n");
  setup_term();

  /* error handling - reset leds */
  atexit(closing_time);
  signal(SIGINT, (void *)closing_time);

  printd("Setting up threads\n");
  start_threads();

  printf("press 'e' and 'enter' to toggle emergency state\n");
  printf("press 'x' and 'enter' to exit\n");

  while((ret = getchar()) != 'x' && alive){
    if (ret == 'e'){
      pthread_mutex_lock(&state_Mutex);
      if (state == EMERGENCY){
        state = prev_state;
        if(state == SUBMENU_SELECT){
          state = MENU_SELECT;
        }
      }
      else {
        prev_state = state;
        state = EMERGENCY;
      }
  	  pthread_cond_broadcast(&state_Signal);
	  pthread_mutex_unlock(&state_Mutex);

      pthread_mutex_lock(&button_Mutex);  // Unlock state machine
      pthread_cond_broadcast(&button_Signal);
      pthread_mutex_unlock(&button_Mutex);

    }
  }
  alive = FALSE; // fallen out by pressing 'x'
  return 0;
}
Пример #5
0
/* int main(int argc, char *argv[]) { */
int main(void) {

   unsigned short drive=8;
   char input;

   do {
      /* a little effect */
      scrollScreen();

      mainMenu();
      input=getchar();

      switch (input) {

         case '1':
                   scrollScreen();
                   drive=baseSetup();
                   break;

         case '2':
                   scrollScreen();
                   boardSetup(drive);
                   break;

         case '3':
                   scrollScreen();
                   networkSetup(drive);
                   break;
 
         case '4':
                   scrollScreen();
                   userSetup(drive);
                   break;
 
         default:
                   break;

      }
 
   } while (input != 'q');

   return 0;
}
Пример #6
0
void main()
{
    networkSetup();
    if (create_connect())exit(0);
    sleep(1);
    create_full();
    connectToServer();

    //control() in new thread
    int unused = 0;
    pthread_t controlThread;
    int threadError = pthread_create (&controlThread,NULL,control, &unused);
    if(threadError)
    {
        printf("thread could not be started! \nerror: %d \nexiting program!\n",threadError);
        exit(0);
    }

    serverCommunication();
}
Пример #7
0
ANetNodeInstance * ANetNodeInstance::nextNode( void ) {
    return networkSetup()->findNext( this );
}
Пример #8
0
State_t WLanRun::detectState( void ) {

    // unavailable : no card found
    // available : card found and assigned to us or free
    // up : card found and assigned to us and up

    NetworkSetup * NC = networkSetup();
    QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number());
    System & Sys = NSResources->system();
    InterfaceInfo * Run;

    QFile F( S );

    if( F.open( IO_ReadOnly ) ) {
      // could open file -> read interface and assign
      QString X;
      QTextStream TS(&F);
      X = TS.readLine();
      // find interface
      if( handlesInterface( X ) ) {
        for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
             It.current();
             ++It ) {
          Run = It.current();
          if( X == Run->Name ) {
            NC->assignInterface( Run );
            return (Run->IsUp) ? IsUp : Available;
          }
        }
      }
    }

    if( ( Run = NC->assignedInterface() ) ) {
      // we already have an interface assigned -> still present ?
      if( ! Run->IsUp ) {
        // usb is still free -> keep assignment
        return Available;
      } // else interface is up but NOT us -> some other profile
    }

    // nothing (valid) assigned to us
    NC->assignInterface( 0 );

    // find possible interface
    for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
         It.current();
         ++It ) {
      Run = It.current();
      if( handlesInterface( *Run ) &&
          ( Run->CardType == ARPHRD_ETHER
#ifdef ARPHRD_IEEE1394
            || Run->CardType == ARPHRD_IEEE1394
#endif
          ) &&
          ! Run->IsUp
        ) {
        // proper type, and Not UP -> free
        return Off;
      }
    }

    return Unavailable;

}