Squashed 'DCPlugin/' changes from e5a8cfd..3e3e1ef
3e3e1ef Make sure the printer functions can be called without explicitly openeing the serial device. git-subtree-dir: DCPlugin git-subtree-split: 3e3e1efe7d77c71f0101f35c8b38419e877f5636
This commit is contained in:
		@@ -148,12 +148,12 @@ public:
 | 
			
		||||
                                  QVector<int> templateIdx,
 | 
			
		||||
                                  QVector<QString> fnames,
 | 
			
		||||
                                  QString br,
 | 
			
		||||
                                  QString serial) const override;
 | 
			
		||||
                                  QString serial = QString()) const override;
 | 
			
		||||
 | 
			
		||||
    bool dc_printTemplate(enum FileTypeJson type,
 | 
			
		||||
                          QVector<int> templateIdx,
 | 
			
		||||
                          QString br,
 | 
			
		||||
                          QString serial) const override;
 | 
			
		||||
                          QString serial = QString()) const override;
 | 
			
		||||
    // ------------------------------------------------------------------------------
 | 
			
		||||
    // Level 1, control device-controller (functions of µC)
 | 
			
		||||
    // check serial connection to deviceController
 | 
			
		||||
 
 | 
			
		||||
@@ -310,12 +310,12 @@ public:
 | 
			
		||||
                                          QVector<int> templateIdx,
 | 
			
		||||
                                          QVector<QString> fnames,
 | 
			
		||||
                                          QString br,
 | 
			
		||||
                                          QString serial) const = 0;
 | 
			
		||||
                                          QString serial = QString()) const = 0;
 | 
			
		||||
 | 
			
		||||
    virtual bool dc_printTemplate(enum FileTypeJson type,
 | 
			
		||||
                                  QVector<int> templateIdx,
 | 
			
		||||
                                  QString br,
 | 
			
		||||
                                  QString serial) const = 0;
 | 
			
		||||
                                  QString serial = QString()) const = 0;
 | 
			
		||||
 | 
			
		||||
    virtual void dc_autoRequest(bool on)  const =0;
 | 
			
		||||
        // on = true:  select that all READ-Requests are sent automatically 
 | 
			
		||||
 
 | 
			
		||||
@@ -438,16 +438,20 @@ bool hwapi::dc_updatePrinterTemplate(enum FileTypeJson type,
 | 
			
		||||
 | 
			
		||||
    qDebug() << "updating: " << fnames << br << serial << "...";
 | 
			
		||||
 | 
			
		||||
    if (!serial.isNull()) {
 | 
			
		||||
        if (!openSerial(baudrateMap.value(br), br, serial)) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    int nTry = 50;
 | 
			
		||||
    while (!sys_ready4sending()) { // wait max. 5 seconds
 | 
			
		||||
        std::this_thread::sleep_for(std::chrono::milliseconds(100));
 | 
			
		||||
        if (--nTry <= 0) {
 | 
			
		||||
            qCritical() << "sys not ready for sending";
 | 
			
		||||
            if (!serial.isNull()) {
 | 
			
		||||
                closeSerial(serial);
 | 
			
		||||
            }
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -471,7 +475,9 @@ bool hwapi::dc_updatePrinterTemplate(enum FileTypeJson type,
 | 
			
		||||
            continue;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (!serial.isNull()) {
 | 
			
		||||
        closeSerial(serial);
 | 
			
		||||
    }
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -496,16 +502,20 @@ bool hwapi::dc_printTemplate(enum FileTypeJson type,
 | 
			
		||||
 | 
			
		||||
    qDebug() << "printing: " << templateIdx << br << serial << "...";
 | 
			
		||||
 | 
			
		||||
    if (!serial.isNull()) {
 | 
			
		||||
        if (!openSerial(baudrateMap.value(br), br, serial)) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    int nTry = 50;
 | 
			
		||||
    while (!sys_ready4sending()) { // wait max. 5 seconds
 | 
			
		||||
        std::this_thread::sleep_for(std::chrono::milliseconds(100));
 | 
			
		||||
        if (--nTry <= 0) {
 | 
			
		||||
            qCritical() << "sys not ready for sending";
 | 
			
		||||
            if (!serial.isNull()) {
 | 
			
		||||
                closeSerial(serial);
 | 
			
		||||
            }
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -520,7 +530,9 @@ bool hwapi::dc_printTemplate(enum FileTypeJson type,
 | 
			
		||||
            continue;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (!serial.isNull()) {
 | 
			
		||||
        closeSerial(serial);
 | 
			
		||||
    }
 | 
			
		||||
    return ret;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user