/** * @brief UAVObjectUtilManager::saveObjectToSD Add a new object to save in the queue * @param obj * * This method only tells the remote end to save the object to its persistent storage (flash * usually), but does not send the object over the telemetry link beforehand. It is therefore * up to the programmer to make sure the object is in the right state on the remote end before * calling this method - the "SmartSave" feature in the ConfigTaskWidget does this, for instance. * * We need to manage a save queue, because once a save request is sent, we need to wait until we * get an update from the remote end telling us whether the operation was successful. If we don't * manage the queue, then we will end up sending save requests one after another and won't be able * to monitor success or failure at all. * * The objectPersistence UAVObject works as follows: * - Set the ObjecID and InstanceID for the target object * - Set the operation ('save' for instance) * - Then update the object, which sends it over the telemetry link * - Once the objectPersistence UAVO is updated, the board will in turn update it again, * once the operation is completed. We need therefore to listen to updates on the objectPersistence * object, and check the "Operation" field, which should be set to "completed", or "error". */ void UAVObjectUtilManager::saveObjectToFlash(UAVObject *obj) { // Add to queue queue.enqueue(obj); qDebug() << "Enqueue object: " << obj->getName(); // If queue length is one, then start sending (call sendNextObject) // Otherwise, do nothing, because we are already sending. if (queue.length()==1) saveNextObject(); }
/* Add a new object to save in the queue */ void UAVObjectUtilManager::saveObjectToSD(UAVObject *obj) { // Add to queue queue.enqueue(obj); qDebug() << "Enqueue object: " << obj->getName(); // If queue length is one, then start sending (call sendNextObject) // Otherwise, do nothing, it's sending anyway if (queue.length() == 1) { saveNextObject(); } }