ed-chemnitz / qmodbus

GNU General Public License v2.0
279 stars 128 forks source link

batch processing ID& Registers #24

Open claudioliciotti opened 5 years ago

claudioliciotti commented 5 years ago

coud be possible to receive info about the syntax that should be used in the "ID & registers" field for Batch processing?

IniterWorker commented 4 years ago

Batch Processing Logic

void BatchProcessor::runBatch()
{
    const int func = stringToHex( embracedString( ui->functionCode->currentText() ) );

    const QStringList slaves = ui->slaveEdit->text().split( ';' );

    QTextStream out( &m_outputFile );

    foreach( const QString &slaveCfg, slaves )
    {
        if( slaveCfg.contains( ':' ) )
        {
            const int slaveID = slaveCfg.split( ':' ).first().toInt();
            const QStringList addresses = slaveCfg.split( ':' ).last().split( ',' );
            foreach( const QString &addr, addresses )
            {
                out << QDateTime::currentDateTime().toTime_t() << slaveID << ", " << addr.toInt() << ", " << sendModbusRequest( slaveID, func, addr.toInt() ) << endl;
            }
        }
    }
}

Review

I'm not currently sure about how it works in deep.

Basic

#ID:#Addr,#Addr

Advanced

#ID:#Addr,#Addr;#ID:#Addr,#Addr;#ID:#Addr,#Addr;#ID:#Addr,#Addr