Example #1
0
void MarkerStorage::generateMarkers(PCube fromCube, const Area* fromArea)
{
	Context* context = Context::getContext();
	CPDatabase db = CONST_COMMITABLE_CAST(Database, context->getParent(fromCube));
	PEngineBase engine = context->getServer()->getEngine(EngineBase::CPU, false);

	PCubeArea ca(new CubeArea(db, fromCube, *fromArea));
	PArea area = ca->expandStar(CubeArea::BASE_ELEMENTS);

	//go through string storage
	PSourcePlanNode sn(new SourcePlanNode(fromCube->getStringStorageId(), area, fromCube->getObjectRevision()));
	PProcessorBase cs = engine->createProcessor(sn, true);
	while (cs->next()) {
		addMarker(cs->getKey());
	}
	//go through numeric storage
	sn.reset(new SourcePlanNode(fromCube->getNumericStorageId(), area, fromCube->getObjectRevision()));
	cs = engine->createProcessor(sn, true);
	while (cs->next()) {
		addMarker(cs->getKey());
	}
	//go through marker storage
	sn.reset(new SourcePlanNode(fromCube->getMarkerStorageId(), area, fromCube->getObjectRevision())); // TODO: -jj- right version object?
	cs = engine->createProcessor(sn, true);
	while (cs->next()) {
		addMarker(cs->getKey());
	}

	//go through changedCells
	PCellMapPlanNode cmpn(new CellMapPlanNode(fromCube->getMarkerStorageId(), area));
	cs = engine->createProcessor(cmpn, true);
	while (cs->next()) {
		addMarker(cs->getKey());
	}
}
Example #2
0
/*
============
olastring::StripTrailingOnce
============
*/
bool olastring::stripTrailingOnce( const char *string ) {
	int l;

	l = strlen( string );
	if ( ( l > 0 ) && ( len >= l ) && !cmpn( string, data + len - l, l ) ) {
		len -= l;
		data[len] = '\0';
		return true;
	}
	return false;
}
Example #3
0
/*
============
olastring::StripLeading
============
*/
void olastring::stripTrailing( const char *string ) {
	int l;

	l = strlen( string );
	if ( l > 0 ) {
		while ( ( len >= l ) && !cmpn( string, data + len - l, l ) ) {
			len -= l;
			data[len] = '\0';
		}
	}
}
Example #4
0
/*
============
olastring::StripLeadingOnce
============
*/
bool olastring::stripLeadingOnce( const char *string ) {
	int l;

	l = strlen( string );
	if ( ( l > 0 ) && !cmpn( string, l ) ) {
		memmove( data, data + l, len - l + 1 );
		len -= l;
		return true;
	}
	return false;
}
Example #5
0
/*
============
olastring::StripLeading
============
*/
void olastring::stripLeading( const char *string ) {
	int l;

	l = strlen( string );
	if ( l > 0 ) {
		while ( !cmpn( string, l ) ) {
			memmove( data, data + l, len - l + 1 );
			len -= l;
		}
	}
}
Example #6
0
void pan1322::Parse(uint8_t c)
{
	uint8_t param;
	uint8_t tmp;
	uint8_t n;

//	DEBUG("P %c %d,%d\n", c, this->p_state, this->p_len);

	uint8_t state = this->p_state;
	switch (state)
	{
	case(BT_STATE_START):
		if (c == '+')
		{
			this->p_state = BT_STATE_RESP;
			this->p_len = 4;
			this->p_index = 0;
			break;
		}
		if (c == 'E')
		{
			this->p_state = BT_STATE_ERR;
			this->p_len = 4;
			this->p_index = 0;
			break;
		}
		if (c == 'O')
		{
			this->p_state = BT_STATE_OK;
			break;
		}
		if (c == 'R')
		{
			this->p_state = BT_STATE_ROK;
			this->p_len = 2;
			this->p_index = 0;
			break;
		}
	break;

	case(BT_STATE_ROK):
		if (this->p_len > this->p_index)
		{
			this->p_buff[this->p_index] = c;
			this->p_index++;
		}
		else
		{
			if (cmpn(this->p_buff, "OK", 2))
			{
				DEBUG("pan1322 reset ok\n");
				this->p_cmd = pan_cmd_set_name;
				this->p_state = BT_STATE_FIND_RN;
			}
		}
	break;

	case(BT_STATE_OK):
		if (c == 'K')
		{
			this->timer = BT_NO_TIMEOUT;

//			DEBUG("OK %d\n", this->p_last_cmd);

			switch(this->p_last_cmd)
			{
				case(pan_cmd_set_name):
					this->p_cmd = pan_cmd_create_service;
				break;

				case(pan_cmd_create_service):
					this->p_cmd = pan_cmd_set_discoverable;
				break;

				case(pan_cmd_set_discoverable):
					DEBUG("pan1322 init ok\n");

					bt_irgh(BT_IRQ_INIT_OK, 0);
				break;
			}
		}
		this->p_state = BT_STATE_FIND_RN;
	break;

	case(BT_STATE_FIND_RN):
		if (c == '\n')
		{
			this->p_state = BT_STATE_START;
		}
	break;

	case(BT_STATE_ERR):
		if (this->p_len > this->p_index)
		{
			this->p_buff[this->p_index] = c;
			this->p_index++;
		}
		else
		{
			if (cmpn(this->p_buff, "RR=-", 4))
			{
				param = c - '0';
				this->error = true;
				this->p_state = BT_STATE_FIND_RN;
				bt_irgh(BT_IRQ_ERROR, &param);
			}
		}
	break;

	case(BT_STATE_RESP):
		if (this->p_len > this->p_index)
		{
			this->p_buff[this->p_index] = c;
			this->p_index++;
		}
		else
		{
			if (cmpn(this->p_buff, "RSLE", 4))
			{
				//pair sucesfull
				this->p_state = BT_STATE_FIND_RN;
				bt_irgh(BT_IRQ_PAIR, 0);
				break;
			}
			if (cmpn(this->p_buff, "RCOI", 4))
			{
				//TODO: decode btaddress
				this->p_state = BT_STATE_FIND_RN;

//				this->AcceptConnection();
				this->p_cmd = pan_cmd_accept_connection;
				break;
			}
			if (cmpn(this->p_buff, "RCCR", 4))
			{
				//device connected
				this->p_state = BT_STATE_FIND_RN;

				this->connected = true;
				bt_irgh(BT_IRQ_CONNECTED, 0);
				break;
			}
			if (cmpn(this->p_buff, "RDII", 4))
			{
				//device disconnected
				this->p_state = BT_STATE_FIND_RN;

				this->connected = false;
				bt_irgh(BT_IRQ_DISCONNECTED, 0);
				break;
			}
			if (cmpn(this->p_buff, "RDAI", 4))
			{
				//incoming data

				this->p_state = BT_STATE_DATA;
				this->p_len = 0;
				break;
			}

			this->p_state = BT_STATE_FIND_RN;
		}


	break;

	case(BT_STATE_DATA):
		tmp = this->p_len;

		switch(tmp)
		{
		case(0): // first digit
			this->p_len++;

			n = c - '0';
			assert(n <= 9);
			if (n > 9)
			{
				this->p_state = BT_STATE_START;
				break;
			}
			this->data_len += 100 * n;

			break;
		case(1): // second digit
			this->p_len++;

			n = c - '0';
			assert(n <= 9);
			if (n > 9)
			{
				this->p_state = BT_STATE_START;
				break;
			}
			this->data_len += 10 * n;

			break;
		case(2): // third digit
			this->p_len++;

			n = c - '0';
			assert(n <= 9);
			if (n > 9)
			{
				this->p_state = BT_STATE_START;
				break;
			}
			this->data_len += 1 * n;

			break;
		case(3): // semicolon
			this->p_len++;

			assert(c == ',');
			if (c != ',')
			{
				this->p_state = BT_STATE_START;
				break;
			}
			break;
		case(4): // data
			this->data_len -= 1;

			if (this->data_len == 0)
			{
				this->p_state = BT_STATE_FIND_RN;
			}

			//HANDLE INCOMING DATA HERE
			//...drop data here :)...
			break;

		}
		break;
	}
}