| 356 | } |
| 357 | |
| 358 | bool ProtocolDock::add_protocol_by_id(QString id, bool silent, std::list<pv::data::decode::Decoder*> &sub_decoders) |
| 359 | { |
| 360 | if (_session->get_device()->get_work_mode() != LOGIC) { |
| 361 | dsv_info("Protocol Analyzer\nProtocol Analyzer is only valid in Digital Mode!"); |
| 362 | return false; |
| 363 | } |
| 364 | |
| 365 | int dex = this->get_protocol_index_by_id(id); |
| 366 | if (dex == -1){ |
| 367 | dsv_err("Protocol not exists! id:%s", id.toUtf8().data()); |
| 368 | return false; |
| 369 | } |
| 370 | |
| 371 | srd_decoder *const decoder = (srd_decoder *)(_decoderInfoList[dex]->_data_handle); |
| 372 | DecoderStatus *dstatus = new DecoderStatus(); |
| 373 | dstatus->m_format = (int)DecoderDataFormat::hex; |
| 374 | |
| 375 | QString protocolName(decoder->name); |
| 376 | QString protocolId(decoder->id); |
| 377 | |
| 378 | if (sub_decoders.size()){ |
| 379 | auto it = sub_decoders.end(); |
| 380 | it--; |
| 381 | protocolName = QString((*it)->decoder()->name); |
| 382 | protocolId = QString((*it)->decoder()->id); |
| 383 | } |
| 384 | |
| 385 | pv::view::Trace *trace = NULL; |
| 386 | |
| 387 | if (_session->add_decoder(decoder, silent, dstatus, sub_decoders, trace) == false){ |
| 388 | return false; |
| 389 | } |
| 390 | |
| 391 | // create item layer |
| 392 | ProtocolItemLayer *layer = new ProtocolItemLayer(_top_panel, protocolName, this); |
| 393 | _protocol_lay_items.push_back(layer); |
| 394 | _top_layout->insertLayout(_protocol_lay_items.size(), layer); |
| 395 | layer->m_decoderStatus = dstatus; |
| 396 | layer->m_protocolId = protocolId; |
| 397 | layer->_trace = trace; |
| 398 | |
| 399 | // set current protocol format |
| 400 | string fmt = AppConfig::Instance().GetProtocolFormat(protocolId.toStdString()); |
| 401 | if (fmt != "") |
| 402 | { |
| 403 | layer->SetProtocolFormat(fmt.c_str()); |
| 404 | dstatus->m_format = DecoderDataFormat::Parse(fmt.c_str()); |
| 405 | } |
| 406 | |
| 407 | // progress connection |
| 408 | const auto &decode_sigs = _session->get_decode_signals(); |
| 409 | protocol_updated(); |
| 410 | connect(decode_sigs.back(), SIGNAL(decoded_progress(int)), this, SLOT(decoded_progress(int))); |
| 411 | |
| 412 | adjustPannelSize(); |
| 413 | |
| 414 | return true; |
| 415 | } |
no test coverage detected