Beispiel #1
0
//==============================================================================
void EndEffector::copyNodeStateTo(std::unique_ptr<Node::State>& outputState) const
{
  if(outputState)
  {
    EndEffector::State* state =
        static_cast<EndEffector::State*>(outputState.get());

    state->mRelativeTransform = mRelativeTf;
    copyAddonStatesTo(state->mAddonStates);
  }
  else
  {
    outputState = getNodeState();
  }
}
Beispiel #2
0
void NMTThread::run()
{
    QString result;

    master_Data.NMTable[this->node_id] = Unknown_state;

    QTime time;
    time.start();

    e_nodeState state = Unknown_state;
    while(time.elapsed() < this->timeout_ms)
    {
        state = getNodeState(&master_Data, this->node_id);
        if (state != Unknown_state)
            break;

    }

    switch (state) {
    case Initialisation:
        result = "Initialisation";
        break;
    case Disconnected:
        result = "Disconnected";
        break;
    case Connecting:
        result = "Connecting";
        break;
    case Pre_operational:
        result = "Pre_operational";
        break;
    case Operational:
        result = "Operational";
        break;
    case Stopped:
        result = "Stopped";
        break;
    default:
        result = "Unknown_state";
        break;
    }
qDebug()<<result;
    emit resultReady(result);
}
Beispiel #3
0
UNS8 GetChangeStateResults(UNS8 node_id, UNS8 expected_state, unsigned long timeout_ms)
   {
   unsigned long start_time = 0;
   
   // reset nodes state
   win32test_Data.NMTable[node_id] = Unknown_state;

   // request node state
   masterRequestNodeState(&win32test_Data, node_id);
   
   start_time = uptime_ms_proc();
   while(uptime_ms_proc() - start_time < timeout_ms)
      {
      if (getNodeState(&win32test_Data, node_id) == expected_state)
         return 0;
      sleep_proc(1);   
      }
   return 0xFF;
   }
RC searchKey(BTreeHandle *tree, PageNumber nodePage, Value *key, RID *result,
		BT_KeyPosition *kp) {
	RC rc;

	// get node state
	int nodeState;
	rc = -99;
	rc = getNodeState(tree, nodePage, &nodeState);

	if (rc != RC_OK) {
		return rc;
	}

	// bottom up condition

	// try to find the key, if found, store the RID into result
	// if not, store the leaf node page number and key position into the result
	rc = -99;
	rc = searchMatchEntry(tree, nodePage, key, result, kp);

	if (rc != RC_OK) {
		return rc;
	}

	// if current node is a not a leaf, then search from its child again
	if (nodeState != 2) {
		rc = -99;
		rc = searchKeyFromRoot(tree, result->page, key, result, kp);

		if (rc != RC_OK) {
			return rc;
		}
	}

	return RC_OK;
}
Beispiel #5
0
//==============================================================================
void Node::copyNodeStateTo(std::unique_ptr<State>& outputState) const
{
  outputState = getNodeState();
}
RC searchMatchEntry(BTreeHandle *tree, PageNumber nodePage, Value *key,
		RID *result, BT_KeyPosition *kp) {
	RC rc;

	int i = 0;
	int resultInt[2];

	// get n
	int n;
	rc = -99;
	rc = getN(tree, &n);

	if (rc != RC_OK) {
		return rc;
	}

	// get key
	int keyInt;
	rc = -99;
	rc = getKey(tree, i, nodePage, &keyInt);

	if (rc != RC_OK) {
		return rc;
	}

	while (i < n && key->v.intV > keyInt) {
		rc = -99;
		rc = getKey(tree, ++i, nodePage, &keyInt);

		if (rc != RC_OK) {
			return rc;
		}
	}

	// after the while loop, either i comes to the end of the key array (i == n)
	// or we found a key that meets (key->v.intV <= keyInt)

	// get the key pointer
	rc = -99;
	rc = getKeyPointer(tree, i, nodePage, resultInt);

	if (rc != RC_OK) {
		return rc;
	}

	// store the current node page number and key position
	kp->nodePage = nodePage; // leaf node page number
	kp->keyPos = i; // key position, starts from 0

	// store the key pointer
	result->page = resultInt[0];
	result->slot = resultInt[1];

	// get node state
	int nodeState;
	rc = -99;
	rc = getNodeState(tree, nodePage, &nodeState);

	if (rc != RC_OK) {
		return rc;
	}

	// if the current node is not node, return RC_KEY_SCOPE_FOUND
	if (nodeState != 2) {
		return RC_KEY_SCOPE_FOUND;
	}

	// if the current is a leaf node, then remove the situation of the key is found (key->v.intV == keyInt)
	// i comes to the end (i = n), or (i < n) if find a scope (key->v->intV < keyInt)
	// then return RC_IM_KEY_NOT_FOUND
	if (i == n || key->v.intV < keyInt) {
		return RC_IM_KEY_NOT_FOUND;
	}

	return RC_OK;
}