@@ -456,19 +456,26 @@ void CiMainGenerator::WriteSigStructField(const SignalDescriptor_t& sig, bool bi
456
456
457
457
fwriter->AppendLine (" " , 2 );
458
458
459
- if (sig.IsDoubleSig )
459
+ if (! sig.IsSimpleSig )
460
460
{
461
461
// this code only required be d-signals (floating point values based)
462
462
// it placed additional signals to struct for conversion
463
463
// to/from physical values. For non-simple and non-double signal
464
464
// there is no necessity to create addition fields
465
465
// @sigfloat_t must be typedefed by user (e.g. double / float)
466
+
467
+ // UPD: from this commit, all non-Simple signals has it's
468
+ // own 'shadow' (_phys) copies, the problem with intermediate type (not simpe and
469
+ // not double) is that the x = ***_toS(x) takes place in each Pack_* call
470
+ // the signals which are not changing from Pack_* to Pack_* will change its values (!)
466
471
fwriter->AppendLine (StrPrint (" #ifdef %s" , fdesc->usesigfloat_def .c_str ()));
467
472
468
- fwriter->AppendLine (StrPrint (" sigfloat_t %s_phys;" , sig.Name .c_str ()));
473
+ if (sig.IsDoubleSig )
474
+ fwriter->AppendLine (StrPrint (" sigfloat_t %s;" , sig.NameFloat .c_str ()));
475
+ else
476
+ fwriter->AppendLine (StrPrint (" %s %s;" , PrintType ((int )sig.Type ).c_str (), sig.NameFloat .c_str ()));
469
477
470
478
fwriter->AppendLine (StrPrint (" #endif // %s" , fdesc->usesigfloat_def .c_str ()), 2 );
471
-
472
479
}
473
480
}
474
481
@@ -484,23 +491,14 @@ void CiMainGenerator::WriteUnpackBody(const CiExpr_t* sgs)
484
491
fwriter->AppendLine (StrPrint (" _m->%s = %s;" , sname, expr.c_str ()));
485
492
486
493
// print sigfloat conversion
487
- if (sgs->msg .Signals [num].IsDoubleSig )
494
+ if (! sgs->msg .Signals [num].IsSimpleSig )
488
495
{
489
496
fwriter->AppendLine (StrPrint (" #ifdef %s" , fdesc->usesigfloat_def .c_str ()));
490
- fwriter->AppendLine (StrPrint (" _m->%s_phys = (sigfloat_t)(%s_%s_fromS(_m->%s));" , sname, fdesc-> DRVNAME . c_str (), sname ,
491
- sname));
497
+ fwriter->AppendLine (StrPrint (" _m->%s = (sigfloat_t)(%s_%s_fromS(_m->%s));" ,
498
+ sgs-> msg . Signals [num]. NameFloat . c_str (), fdesc-> DRVNAME . c_str (), sname, sname));
492
499
fwriter->AppendLine (StrPrint (" #endif // %s" , fdesc->usesigfloat_def .c_str ()), 2 );
493
500
}
494
501
495
- else if (!sgs->msg .Signals [num].IsSimpleSig )
496
- {
497
- // print unpack conversion for non-simple and non-double signals
498
- // for this case conversion fromS is performed to signal itself
499
- // without (sigfloat_t) type casting
500
- fwriter->AppendLine (StrPrint (" #ifdef %s" , fdesc->usesigfloat_def .c_str ()));
501
- fwriter->AppendLine (StrPrint (" _m->%s = (%s_%s_fromS(_m->%s));" , sname, fdesc->DRVNAME .c_str (), sname, sname));
502
- fwriter->AppendLine (StrPrint (" #endif // %s" , fdesc->usesigfloat_def .c_str ()), 2 );
503
- }
504
502
else if (num + 1 == sgs->to_signals .size ())
505
503
{
506
504
// last signal without phys part, put \n manually
@@ -604,9 +602,9 @@ void CiMainGenerator::PrintPackCommonText(const std::string& arrtxt, const CiExp
604
602
if (sgs->msg .Signals [n].IsDoubleSig )
605
603
{
606
604
// print toS from *_phys to original named sigint (integer duplicate of signal)
607
- fwriter->AppendLine (StrPrint (" _m->%s = %s_%s_toS(_m->%s_phys );" ,
605
+ fwriter->AppendLine (StrPrint (" _m->%s = %s_%s_toS(_m->%s );" ,
608
606
sgs->msg .Signals [n].Name .c_str (), fdesc->DRVNAME .c_str (),
609
- sgs->msg .Signals [n].Name .c_str (), sgs->msg .Signals [n].Name .c_str ()));
607
+ sgs->msg .Signals [n].Name .c_str (), sgs->msg .Signals [n].NameFloat .c_str ()));
610
608
}
611
609
else
612
610
{
0 commit comments