@ -80,8 +80,8 @@ void DBCFile::parse(const QString &content) {
static QRegularExpression bo_regexp ( R " (^BO_ ( \ w+) ( \ w + ) * : ( \ w + ) ( \ w + ) ) " ) ;
static QRegularExpression bo_regexp ( R " (^BO_ ( \ w+) ( \ w + ) * : ( \ w + ) ( \ w + ) ) " ) ;
static QRegularExpression sg_regexp ( R " (^SG_ ( \ w+) : ( \ d + ) \ | ( \ d + ) @ ( \ d + ) ( [ \ + | \ - ] ) \ ( ( [ 0 - 9. + \ - eE ] + ) , ( [ 0 - 9. + \ - eE ] + ) \ ) \ [ ( [ 0 - 9. + \ - eE ] + ) \ | ( [ 0 - 9. + \ - eE ] + ) \ ] \ " (.*) \" (.*)) " ) ;
static QRegularExpression sg_regexp ( R " (^SG_ ( \ w+) : ( \ d + ) \ | ( \ d + ) @ ( \ d + ) ( [ \ + | \ - ] ) \ ( ( [ 0 - 9. + \ - eE ] + ) , ( [ 0 - 9. + \ - eE ] + ) \ ) \ [ ( [ 0 - 9. + \ - eE ] + ) \ | ( [ 0 - 9. + \ - eE ] + ) \ ] \ " (.*) \" (.*)) " ) ;
static QRegularExpression sgm_regexp ( R " (^SG_ ( \ w+) ( \ w + ) * : ( \ d + ) \ | ( \ d + ) @ ( \ d + ) ( [ \ + | \ - ] ) \ ( ( [ 0 - 9. + \ - eE ] + ) , ( [ 0 - 9. + \ - eE ] + ) \ ) \ [ ( [ 0 - 9. + \ - eE ] + ) \ | ( [ 0 - 9. + \ - eE ] + ) \ ] \ " (.*) \" (.*)) " ) ;
static QRegularExpression sgm_regexp ( R " (^SG_ ( \ w+) ( \ w + ) * : ( \ d + ) \ | ( \ d + ) @ ( \ d + ) ( [ \ + | \ - ] ) \ ( ( [ 0 - 9. + \ - eE ] + ) , ( [ 0 - 9. + \ - eE ] + ) \ ) \ [ ( [ 0 - 9. + \ - eE ] + ) \ | ( [ 0 - 9. + \ - eE ] + ) \ ] \ " (.*) \" (.*)) " ) ;
static QRegularExpression msg_comment_regexp ( R " (^CM_ BO_ *( \ w+) * \ " ([^ " ] * ) \ " \ s* ; ) " );
static QRegularExpression msg_comment_regexp ( R " (^CM_ BO_ *( \ w+) * \ " ((?: [^ " \ \ ] | \ \ . ) * ) \ " \ s* ; ) " );
static QRegularExpression sg_comment_regexp ( R " (^CM_ SG_ *( \ w+) * ( \ w + ) * \ " ([^ " ] * ) \ " \ s* ; ) " );
static QRegularExpression sg_comment_regexp ( R " (^CM_ SG_ *( \ w+) * ( \ w + ) * \ " ((?: [^ " \ \ ] | \ \ . ) * ) \ " \ s* ; ) " );
static QRegularExpression val_regexp ( R " (VAL_ ( \ w+) ( \ w + ) ( \ s * [ - + ] ? [ 0 - 9 ] + \ s + \ " .+? \" [^ ; ] * ) ) " );
static QRegularExpression val_regexp ( R " (VAL_ ( \ w+) ( \ w + ) ( \ s * [ - + ] ? [ 0 - 9 ] + \ s + \ " .+? \" [^ ; ] * ) ) " );
int line_num = 0 ;
int line_num = 0 ;
@ -173,7 +173,7 @@ void DBCFile::parse(const QString &content) {
auto match = msg_comment_regexp . match ( line ) ;
auto match = msg_comment_regexp . match ( line ) ;
dbc_assert ( match . hasMatch ( ) ) ;
dbc_assert ( match . hasMatch ( ) ) ;
if ( auto m = ( cabana : : Msg * ) msg ( match . captured ( 1 ) . toUInt ( ) ) ) {
if ( auto m = ( cabana : : Msg * ) msg ( match . captured ( 1 ) . toUInt ( ) ) ) {
m - > comment = match . captured ( 2 ) . trimmed ( ) ;
m - > comment = match . captured ( 2 ) . trimmed ( ) . replace ( " \\ \" " , " \" " ) ;
}
}
} else if ( line . startsWith ( " CM_ SG_ " ) ) {
} else if ( line . startsWith ( " CM_ SG_ " ) ) {
if ( ! line . endsWith ( " \" ; " ) ) {
if ( ! line . endsWith ( " \" ; " ) ) {
@ -183,7 +183,7 @@ void DBCFile::parse(const QString &content) {
auto match = sg_comment_regexp . match ( line ) ;
auto match = sg_comment_regexp . match ( line ) ;
dbc_assert ( match . hasMatch ( ) ) ;
dbc_assert ( match . hasMatch ( ) ) ;
if ( auto s = get_sig ( match . captured ( 1 ) . toUInt ( ) , match . captured ( 2 ) ) ) {
if ( auto s = get_sig ( match . captured ( 1 ) . toUInt ( ) , match . captured ( 2 ) ) ) {
s - > comment = match . captured ( 3 ) . trimmed ( ) ;
s - > comment = match . captured ( 3 ) . trimmed ( ) . replace ( " \\ \" " , " \" " ) ;
}
}
} else {
} else {
seen = false ;
seen = false ;
@ -207,7 +207,7 @@ QString DBCFile::generateDBC() {
const QString transmitter = m . transmitter . isEmpty ( ) ? DEFAULT_NODE_NAME : m . transmitter ;
const QString transmitter = m . transmitter . isEmpty ( ) ? DEFAULT_NODE_NAME : m . transmitter ;
dbc_string + = QString ( " BO_ %1 %2: %3 %4 \n " ) . arg ( address ) . arg ( m . name ) . arg ( m . size ) . arg ( transmitter ) ;
dbc_string + = QString ( " BO_ %1 %2: %3 %4 \n " ) . arg ( address ) . arg ( m . name ) . arg ( m . size ) . arg ( transmitter ) ;
if ( ! m . comment . isEmpty ( ) ) {
if ( ! m . comment . isEmpty ( ) ) {
comment + = QString ( " CM_ BO_ %1 \" %2 \" ; \n " ) . arg ( address ) . arg ( m . comment ) ;
comment + = QString ( " CM_ BO_ %1 \" %2 \" ; \n " ) . arg ( address ) . arg ( QString ( m . comment ) . replace ( " \" " , " \\ \" " ) ) ;
}
}
for ( auto sig : m . getSignals ( ) ) {
for ( auto sig : m . getSignals ( ) ) {
QString multiplexer_indicator ;
QString multiplexer_indicator ;
@ -230,7 +230,7 @@ QString DBCFile::generateDBC() {
. arg ( sig - > unit )
. arg ( sig - > unit )
. arg ( sig - > receiver_name . isEmpty ( ) ? DEFAULT_NODE_NAME : sig - > receiver_name ) ;
. arg ( sig - > receiver_name . isEmpty ( ) ? DEFAULT_NODE_NAME : sig - > receiver_name ) ;
if ( ! sig - > comment . isEmpty ( ) ) {
if ( ! sig - > comment . isEmpty ( ) ) {
comment + = QString ( " CM_ SG_ %1 %2 \" %3 \" ; \n " ) . arg ( address ) . arg ( sig - > name ) . arg ( sig - > comment ) ;
comment + = QString ( " CM_ SG_ %1 %2 \" %3 \" ; \n " ) . arg ( address ) . arg ( sig - > name ) . arg ( QString ( sig - > comment ) . replace ( " \" " , " \\ \" " ) ) ;
}
}
if ( ! sig - > val_desc . empty ( ) ) {
if ( ! sig - > val_desc . empty ( ) ) {
QStringList text ;
QStringList text ;