コード例 #1
0
ファイル: SignalPainter.cpp プロジェクト: hcmlab/mobileSSI
void SignalPainter::consume (IConsumer::info consume_info,
	ssi_size_t stream_in_num,
	ssi_stream_t stream_in[]) {

	for (ssi_size_t i = 0; i < _n_windows; i++) {
		if (_options.type == PaintSignalType::BAR || _options.type == PaintSignalType::BAR_POS) {	
			if (_options.barNames[0] != '\0') {
				ssi_size_t n = ssi_split_string_count(_options.barNames, ',');
				ssi_char_t **tokens = new ssi_char_t *[n];
				ssi_split_string(n, tokens, _options.barNames, ',');
				ssi_pcast(PaintBars, _client[i])->setExternalAxisCaptions(n, tokens);
				for (ssi_size_t j = 0; j < n; j++) {
					delete[] tokens[j];
				}
				delete[] tokens;
			}
			if (_options.reset) {
				ssi_pcast(PaintBars, _client[i])->reset();
			}
			ssi_pcast(PaintBars, _client[i])->setData(stream_in[i]);
		} else {
			if (_options.reset) {
				ssi_pcast(PaintSignal, _client[i])->resetLimits();
			}
			ssi_pcast(PaintSignal, _client[i])->setData(stream_in[i], consume_info.time);
		}
		_canvas[i]->update();
	}
}
コード例 #2
0
ファイル: EventAddress.cpp プロジェクト: hihiy/IntelliVoice
void EventAddress::parseAddress (const ssi_char_t *address) {

    if (address == 0 || address[0] == '\0') {
        return;
    }

    size_t len = strlen (address);

    ssi_char_t *chunks[2];

    if (address[0] == '@') {
        chunks[0] = 0;
        chunks[1] = ssi_strcpy (address + 1);
    } else if (address[len-1] == '@') {
        chunks[0] = ssi_strcpy (address);
        chunks[0][len-1] = '\0';
        chunks[1] = 0;
    } else {
        ssi_size_t n_chunks = ssi_split_string_count (address, '@');
        if (n_chunks != 2) {
            ssi_wrn ("malformed event address '%s'", address);
            return;
        }
        ssi_split_string (2, chunks, address, '@');
    }

    parseNames (chunks[0], _n_events, &_events);
    parseNames (chunks[1], _n_sender, &_sender);

    delete[] chunks[0];
    delete[] chunks[1];
}
コード例 #3
0
ファイル: MapEventSender.cpp プロジェクト: hcmlab/mobileSSI
void MapEventSender::consume_enter (ssi_size_t stream_in_num,
	ssi_stream_t stream_in[]) {

	if (stream_in[0].type != SSI_REAL) {
		ssi_err ("type '%s' not supported", SSI_TYPE_NAMES[stream_in[0].type]);
	}

	ssi_size_t dim = stream_in[0].dim;

	ssi_event_adjust(_event, sizeof(ssi_event_map_t) * dim);
	ssi_event_map_t *dst = ssi_pcast(ssi_event_map_t, _event.ptr);

	ssi_char_t **keys = 0;
	if (_options.keys[0] != '\0') {
		ssi_size_t n = ssi_split_string_count(_options.keys, ',');
		keys = new ssi_char_t *[dim];
		ssi_split_string(n, keys, _options.keys, ',');
		for (ssi_size_t i = n; i < dim; i++) {			
			keys[i] = ssi_strcpy(keys[i%n]);
		}
	}

	ssi_char_t str[512];
	if (keys) {
		for (ssi_size_t i = 0; i < dim; i++) {
			dst++->id = Factory::AddString(keys[i]);
		}
	} else {
		for (ssi_size_t i = 0; i < dim; i++) {
			ssi_sprint(str, "dim#%u", i);
			dst++->id = Factory::AddString(str);
		}
	}

	if (keys) {
		for (ssi_size_t i = 0; i < dim; i++) {
			delete[] keys[i];
		}
		delete[] keys; keys = 0;
	}
}
コード例 #4
0
ファイル: EventAddress.cpp プロジェクト: hihiy/IntelliVoice
void EventAddress::parseNames (const ssi_char_t *names, ssi_size_t &n, ssi_char_t ***target) {

    ssi_size_t n_new = 0;
    if (names && names[0] != '\0') {
        n_new = ssi_split_string_count (names, ',');
    }

    if (n_new == 0) {
        return;
    }

    ssi_char_t **target_new = new ssi_char_t *[n + n_new];
    for (ssi_size_t i = 0; i < n; i++) {
        target_new[i] = ssi_strcpy ((*target)[i]);
        delete[] (*target)[i];
    }
    delete[] (*target);

    ssi_split_string (n_new, target_new + n, names, ',');

    *target = target_new;
    n += n_new;
}
コード例 #5
0
ファイル: SignalPainter.cpp プロジェクト: hcmlab/mobileSSI
void SignalPainter::consume_enter (ssi_size_t stream_in_num,
	ssi_stream_t stream_in[]) {

	_n_windows = stream_in_num;
	_window = new IWindow *[_n_windows];	
	_canvas = new ICanvas *[_n_windows];
	_client = new ICanvasClient *[_n_windows];

	ssi_char_t **titles = new ssi_char_t *[_n_windows];
	if (_n_windows == 1)
	{
		titles[0] = ssi_strcpy(_options.title);
	} 
	else
	{
		ssi_char_t n_titles = ssi_split_string_count(_options.title, ';');
		if (n_titles == _n_windows)
		{
			ssi_split_string(_n_windows, titles, _options.title, ';');
		}
		else
		{
			ssi_char_t string[SSI_MAX_CHAR];
			for (ssi_size_t i = 0; i < _n_windows; i++)
			{
				ssi_sprint(string, "%s#%02d", _options.title, i);
				titles[i] = ssi_strcpy(string);
			}
		}
	}

	int pos_top = _options.pos[1];
	int pos_height = _options.pos[3] / _n_windows;
	for (ssi_size_t i = 0; i < _n_windows; i++) {

		if (_options.type == PaintSignalType::BAR || _options.type == PaintSignalType::BAR_POS) {
			PaintBars *plot = new PaintBars(_options.type == PaintSignalType::BAR ? PaintBars::TYPE::BAR : PaintBars::TYPE::BAR_POS);
			if (!_options.autoscale){
				plot->setFixedLimit(ssi_cast(ssi_real_t, _options.fix[0]));
			} else {
				if (!_options.reset) {
					plot->setGlobalLimit(false);
				}
			}
			plot->setPrecision(_options.axisPrecision);
			_client[i] = plot;
		} else {
			PaintSignal *plot = new PaintSignal(stream_in[i].sr, stream_in[i].dim, _options.size, _options.type, _options.indx, _options.indy, _options.staticImage);
			plot->setIndices(_options.indx, _options.indy);
			plot->setPrecision(_options.axisPrecision);
			plot->setColormap(_options.colormap);
			if (!_options.autoscale){
				plot->setLimits(ssi_cast(ssi_real_t, _options.fix[0]), ssi_cast(ssi_real_t, _options.fix[1]));
			}
			_client[i] = plot;
		}		

		_canvas[i] = new Canvas();
		_canvas[i]->addClient(_client[i]);

		_window[i] = new Window();
		_window[i]->setClient(_canvas[i]);
			
		_window[i]->setTitle(titles[i]);				
		_window[i]->setPosition(ssi_rect(_options.pos[0], pos_top + i * pos_height, _options.pos[2], pos_height));

		_window[i]->create();
		_window[i]->show();	

		delete[] titles[i];
	}
	delete[] titles;
}