| 12 | } |
| 13 | |
| 14 | void CanDbHandler::processBcast(const QJsonObject& msg, const QVariant& param) |
| 15 | { |
| 16 | QVariant vId = msg["id"]; |
| 17 | QUuid id; |
| 18 | if (vId.isValid()) { |
| 19 | id = QUuid(vId.toString()); |
| 20 | } |
| 21 | |
| 22 | QString name = msg["caption"].toString(); |
| 23 | QString type = msg["name"].toString(); |
| 24 | |
| 25 | QVariant vMsg = msg["msg"]; |
| 26 | if (vMsg.isValid() && vMsg.toString() == BcastMsg::CanDbUpdated) { |
| 27 | CANmessages_t paramMsg; |
| 28 | if (param.isValid()) { |
| 29 | paramMsg = qvariant_cast<CANmessages_t>(param); |
| 30 | } |
| 31 | |
| 32 | _candb[id] = paramMsg; |
| 33 | _dbNames[id] = name; |
| 34 | _dbColor[id] = msg["color"].toString(); |
| 35 | |
| 36 | if (_currentDb.isNull()) { |
| 37 | _currentDb = id; |
| 38 | } |
| 39 | |
| 40 | if (_currentDb == id) { |
| 41 | _props["color"] = _dbColor[id]; |
| 42 | emit requestRedraw(); |
| 43 | emit dbChanged(); |
| 44 | } |
| 45 | } else if ((vMsg.isValid() && vMsg.toString() == BcastMsg::ConfigChanged) && (type == "CanSignalData")) { |
| 46 | _dbNames[id] = name; |
| 47 | |
| 48 | if (msg["config"].isObject()) { |
| 49 | _dbColor[id] = msg["config"].toObject()["color"].toString(); |
| 50 | } |
| 51 | |
| 52 | if (_currentDb == id) { |
| 53 | _props["color"] = _dbColor[id]; |
| 54 | emit requestRedraw(); |
| 55 | } |
| 56 | } else if (vMsg.isValid() && vMsg.toString() == BcastMsg::NodeDeleted) { |
| 57 | _dbNames.erase(id); |
| 58 | _candb.erase(id); |
| 59 | _dbColor.erase(id); |
| 60 | |
| 61 | dbDeleted(id); |
| 62 | } else if (vMsg.isValid() && vMsg.toString() == BcastMsg::InitDone) { |
| 63 | QJsonObject msg; |
| 64 | msg["msg"] = BcastMsg::RequestCanDb; |
| 65 | |
| 66 | emit sendCanDbRequest(msg); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | const CANmessages_t& CanDbHandler::getDb() const |
| 71 | { |
no outgoing calls
no test coverage detected