TITANIUM_FUNCTION(MusicPlayer, setQueue)
		{
			ENSURE_OBJECT_AT_INDEX(js_queue, 0);

			std::vector<std::shared_ptr<Item>> queues;

			const auto queue = js_queue.GetPrivate<Item>();

			if (queue != nullptr) {
				queues.push_back(queue);
			} else if (js_queue.IsArray()) {
				const auto js_array = static_cast<std::vector<JSValue>>(static_cast<JSArray>(js_queue));
				for (const auto v : js_array) {
					queues.push_back(static_cast<JSObject>(v).GetPrivate<Item>());
				}
			} else if (js_queue.HasProperty("items")) {
				// PlayerQueue
				const auto js_playerQueue = static_cast<JSObject>(js_queue.GetProperty("items"));
				if (js_playerQueue.IsArray()) {
					const auto js_array = static_cast<std::vector<JSValue>>(static_cast<JSArray>(js_playerQueue));
					for (const auto v : js_array) {
						queues.push_back(static_cast<JSObject>(v).GetPrivate<Item>());
					}
				}
			}

			setQueue(queues);

			return get_context().CreateUndefined();
		}
Exemplo n.º 2
0
static void backtrack(int n,vector<vector<bool> > state,int total)
{
    if ( n == 0) {//递归终止条件,所有的Q都摆在了棋盘上
        retValue += 1;
        return;
    }
    
    for (int j = 0; j < total; j++) {
        if (state[n-1][j] == true) continue;
        vector<vector<bool> > newState = setQueue(n-1, j, state,total);
        backtrack(n-1, newState, total);
    }
}
Exemplo n.º 3
0
int main(int argc, char **argv) {
  char SrvCmd[_SIZ_MSGBUFF] = { 0 };
  char ClientMsg[_SIZ_MSGBUFF] = { 0 };
  char ErrorMsg[_SIZ_GENFIELD] = { 0 };
  int Status = -1, firstOpt = 0;
  int i = 0;

  firstOpt = HandleOptions(argc, argv);
  if (1 == firstOpt) {
    Usage(argv[0]);
    exit(1);
  }

  ReadConfig();

  if (TRC_OpenEx(LOGFILE, LOGNAME, 9, _TRC_NEXT_DAY, _LOG_2MB_LIMIT) != _RET_SUCCESS) {
    fprintf(stderr, "%s: Test program error: Could not open log file [%s]. Quit.\n", TRC_GetTime(), "stderr");
    TRC_Shutdown();
    exit(1);
  }

  /**** Initialize Alarm Events ****/
  if (TRC_InitAlarm(LOGFILE, config.servername, ShutDownSrv) != _RET_SUCCESS) {
    TRC_Send(LOGFILE, _TRC_LVL_INFO, "%s:FATAL ERROR: Could not Init alarm - program exiting.\n", TRC_GetTime());
    TRC_Shutdown();
    exit(1);
  }
  TRC_Send(LOGFILE, _TRC_LVL_WARN, "%s: Logfile and Alarm Init completed. Setting Queues...\n", TRC_GetTime());
  setQueue();

  do {
    TRC_Send(LOGFILE, _TRC_LVL_INFO, "%s: Waiting for next command:\n", TRC_GetTime());

    Status = TLK_DMQ_ServerGet(hPRIMARY, _TLK_TYPDEL, ClientMsg);
    if (Status != _RET_SUCCESS)
      continue; /* Skip to begining of loop */

    SrvCmd[0] = '\0';
    Status = PRS_VFI_GetToken(_PRS_VFI_CMDID, _SIZ_GENFIELD, SrvCmd);
    if (Status == _RET_SUCCESS)
      vfeiCmd(SrvCmd);
    else
      deliCmd();
  } while (1);
  ShutDownSrv();
  return 0;
}
Exemplo n.º 4
0
PBSConfigurator::PBSConfigurator(QueueList const& queues, QVariantMap const& defaults,
   QWidget* parent) : QDialog(parent), m_queues(queues), m_timeValidator(this)
 
{
   m_dialog.setupUi(this);
   m_dialog.queue->clear();
   if (m_queues.isEmpty()) {
      QMsgBox::warning(this, "IQmol", "No PBS queues found");
      close();
      return;
   }

   QString defaultQueueName;
   if (defaults.contains("Queue")) {
      defaultQueueName = defaults.value("Queue").toString();
    }

   for (int i = 0; i < m_queues.size(); ++i) {
       QString name(m_queues[i]->m_name);
       m_dialog.queue->addItem(name);
       if (name == defaultQueueName) {
          m_dialog.queue->setCurrentIndex(i);

          if (defaults.contains("Walltime")) {
              m_dialog.walltime->setText(defaults.value("Walltime").toString());
          }
          if (defaults.contains("Memory")) {
              m_dialog.memory->setValue(defaults.value("Memory").toInt());
          }
          if (defaults.contains("Jobfs")) {
              m_dialog.jobfs->setValue(defaults.value("Jobfs").toInt());
          }
          if (defaults.contains("Ncpus")) {
              m_dialog.ncpus->setValue(defaults.value("Ncpus").toInt());
          }
       }
   }

   if (defaultQueueName.isEmpty()) setQueue(m_queues.first());
   connect(m_dialog.buttonBox, SIGNAL(accepted()), this, SLOT(verify()));

   QString sixty("(?:[0-5][0-9])");
   m_timeValidator.setRegExp(QRegExp("^\\d+:" + sixty + ":" + sixty));
   m_dialog.walltime->setValidator(&m_timeValidator);
}
void CommandLineInterface::mainMenu() {
  while (true) {
    std::cout << "\n";
    std::cout << "Type a command (type 'help' or 'h' for help)" << std::endl;
    std::cout << "\n";
    std::cout << "> ";
    std::string input;
    std::getline(std::cin, input);
    std::vector<std::string> args = string_utils::split(input);
    if (args.empty()) {
      std::cout << "Invalid input." << std::endl;
    } else {
      std::string command = args[0];
      args.erase(args.begin());
      clearScreen();
      if (command == "create") {
        createEntities(args);
      } else if (command == "remove" || command == "delete") {
        removeEntities(args);
      } else if (command == "list" || command == "l") {
        listEntities(args);
      } else if (command == "setq") {
        setQueue(args);
      } else if (command == "unsetq") {
        unsetQueue(args);
      } else if (command == "start") {
        startQueueHandler(args);
      } else if (command == "stop") {
        stopQueueHandler(args);
      } else if (command == "watch" || command == "w") {
        watch();
      } else if (command == "help" || command == "h") {
        showHelp();
      } else if (command == "quit" || command == "q") {
        std::cout << "Bye." << std::endl;
        break;
      } else {
        std::cout << "Sorry. Command not recognized." << std::endl;
      }
    }
  }
}
Exemplo n.º 6
0
/*Build Minimax Tree for Best Difficulty using BFS Algorithm*/
MinimaxNode *getMinimaxTreeBestDepth(Game *game, Color uCol) {
    MinimaxNode *root = (MinimaxNode*)malloc(sizeof(MinimaxNode));
    if (root == NULL)exitOnError("malloc");
    root->game = (Game*)malloc(sizeof(Game));
    if (root->game == NULL) exitOnError("malloc");
    root->val = 0;
    MinimaxNode *curr;
    ListNode *moves;
    int i;
    int leavesLocal = 1;
    Queue *q = setQueue(); /*Create empty Queue for BFS Traversing*/
    int size = 0;
    root->depth = 0;
    root->move = NULL;
    copyGame(game, root->game);
    root->sons = NULL;
    root->sonsK = 0;
    enqueue(q, root);
    /*While Queue is not empty and there are less than MAX_BOARDS_TO_EVAL Leaves in Tree*/
    while (q->size&&leavesLocal + size <= MAX_BOARDS_TO_EVAL) {
        curr = dequeue(q); /*Pop from Queue*/
        if (curr->depth % 2 == 0)moves = getMoves(curr->game, uCol); /*Get possible Moves at current Board state*/
        else moves = getMoves(curr->game, oppositeCol(uCol));
        size = listSize(moves);
        if (!size) {
            free(moves);
            continue;
        }
        curr->sons = (MinimaxNode**)malloc(sizeof(MinimaxNode)*size);
        if (curr->sons == NULL) exitOnError("malloc");
        curr->sonsK = size;
        ListNode *temp = moves;
        for (i = 0; i < size; i++) { /*Add Nodes for each possible Move*/
            curr->sons[i] = (MinimaxNode*)malloc(sizeof(MinimaxNode));
            if (curr->sons[i] == NULL) exitOnError("malloc");
            curr->sons[i]->game = (Game*)malloc(sizeof(Game));
            if (curr->sons[i]->game == NULL) exitOnError("malloc");
            curr->sons[i]->val = 0;
            copyGame(curr->game, curr->sons[i]->game);
            Move* tMove = copyMove(temp->move);
            updateBoard(curr->sons[i]->game, tMove);
            curr->sons[i]->depth = curr->depth + 1;
            if (curr->sons[i]->depth == 1) {
                curr->sons[i]->move = tMove;
            }
            else {
                freeMove(tMove);
                curr->sons[i]->move = NULL;
            }
            curr->sons[i]->sons = NULL;
            curr->sons[i]->sonsK = 0;
            enqueue(q, curr->sons[i]); /*Push to Queue*/
            temp = temp->next;
        }
        /*Update amount of Leaves in Tree*/
        freeList(moves);
        leavesLocal += size;
        if (size) leavesLocal--;
    }
    freeQueue(q);
    return root;
}
void SSMPQueueDisplayWidget::loadModel() {
	setQueue(new SSMPQueue(loadSSMPQueue("Queue")));
}
SSMPQueueDisplayWidget::SSMPQueueDisplayWidget(const SSMPQueue *queue) :
	queue(queue) {
	setupUi(this);
	setQueue(queue);
}
Exemplo n.º 9
0
TaskProximity::TaskProximity(SI1143* si1143,Mutex* mutexI2C, Queue<SI1143ProximityMessage,PROXIMITY_QUEUE_LENGHT>* queue){
	this->si1143 = si1143;
	setMutex(mutexI2C);
	setQueue(queue);
}
Exemplo n.º 10
0
int main(int argc, char **argv) {

  char SrvCmd[_SIZ_MSGBUFF] = { 0 };
  char ClientMsg[_SIZ_MSGBUFF] = { 0 };
  char ErrorMsg[_SIZ_GENFIELD] = { 0 };
  int Status = -1;
  int i = 0;

  if (TRC_Open("TstLog", "stderr", 9) != _RET_SUCCESS) {
    fprintf(stderr, "%s: Test program error: Could not open log file [%s]. Quit.\n", TRC_GetTime(), "stderr");
    TRC_Shutdown();
    exit(1);
  }

    /**** Initialize Alarm Events ****/
  if (TRC_InitAlarm(LOGFILE, "TESTPROG", ShutDownSrv) != _RET_SUCCESS) {
    TRC_Send(LOGFILE, _TRC_LVL_INFO, "%s:FATAL ERROR: Could not Init alarm - program exiting.\n", TRC_GetTime());
    TRC_Shutdown();
    exit(1);
  }
  TRC_Send(LOGFILE, _TRC_LVL_WARN, "%s: Logfile and Alarm Init completed. Setting Queues...\n", TRC_GetTime());

  setQueue();

  do {

    TRC_Send(LOGFILE, _TRC_LVL_INFO, "%s: Enter CmdText:\n", TRC_GetTime());
    scanf("%[^\n]s", SrvCmd);
    fflush(stdin);
    getchar();
    TRC_Send(LOGFILE, _TRC_LVL_INFO, "Ok.\n");

    if (strcmp(SrvCmd, "SHUTDOWN") == 0) {
      TLK_DMQ_Shutdown();
      TRC_Shutdown();
      break;
    }
    if (strcmp(SrvCmd, "QUEUE") == 0) {
      setTarget();
      continue;
    }
    if (strcmp(SrvCmd, "TEST") == 0) {
      char MCS_GET_LOT_LOC[] = "|MCS_GET_LOT_LOC|MCS_GET_LOT_LOC query|3AAZ42064.1|";
    //  sendCommandAsync(MCS_GET_LOT_LOC);
      char MCS_SEND_LOT_LOC[] = "|MCS_SEND_LOT_LOC|MCS_SEND_LOT_LOC query|3AAZ42064.1|3AMASK1|L0000001|";
      sendCommandAsync(MCS_SEND_LOT_LOC);
      char MCS_CLR_LOT_LOC[] = "|MCS_CLR_LOT_LOC|MCS_CLR_LOT_LOC query|3AAZ42064.1|";
      sendCommandAsync(MCS_CLR_LOT_LOC);
      char MCS_MOVE_LOT_LOC[] = "|MCS_MOVE_LOT_LOC|MCS_MOVE_LOT_LOC query|HPTEST|3AAZ42064.1|3AMASK1|L0000002|1|";
     // sendCommandAsync(MCS_MOVE_LOT_LOC);
      char MCS_GET_LOT_ALL[] = "|MCS_GET_LOT_ALL|MCS_GET_LOT_ALL query|2|3AAZ42064.1|3MKZ48036.1|";
      sendCommandAsync(MCS_GET_LOT_ALL);
      continue;
    }

    PRS_DEL_InitCommand("MCS_MOVE_LOT_LOC", "TestMCS");
    strcpy(message.buffer, SrvCmd);
    message.msgLen = strlen(SrvCmd);
    message.msgPtr = 0;
    TRC_ClrAlarm();
    TLK_DMQ_ClientPut(hTARGET);
    TLK_DMQ_ClientGet(hTARGET);
    if (TRC_ChkAlarm())
      TRC_Send(LOGFILE, _TRC_LVL_INFO, "%s:Reply\n%s\n", TRC_GetTime(), message.buffer);
    else
      TRC_Send(LOGFILE, _TRC_LVL_INFO, "%s:Error %d occurred: %s\n", TRC_GetTime(), TRC_GetAlarm(), TRC_ErrorMsg());
  } while (1);
  ShutDownSrv();
  return 0;
}
Exemplo n.º 11
0
void PBSConfigurator::on_queue_currentIndexChanged(int index)
{
   setQueue(m_queues[index]);
}
Exemplo n.º 12
0
TaskLight::TaskLight(MAX44009* max44009,Mutex* mutexI2C, Queue<MAX44009Message,LIGHT_QUEUE_LENGHT>* queue){
	this->max44009 = max44009;
	setMutex(mutexI2C);
	setQueue(queue);
}