@@ -91,8 +91,7 @@ void CiMainGenerator::Generate(std::vector<MessageDescriptor_t*>& msgs, const Fs
9191 {
9292 SignalDescriptor_t& s = m.Signals [signum];
9393
94- // TODO: print signal to_S and from_S definitions if necessary
95- if (s.IsDoubleSig ==true || ((s.Factor !=1 ) || (s.Offset !=0 )))
94+ if (!s.IsSimpleSig )
9695 {
9796 fwriter->AppendLine (sigprt->PrintPhysicalToRaw (&s, fsd.DRVNAME ));
9897 }
@@ -282,6 +281,21 @@ void CiMainGenerator::WriteSigStructField(const SignalDescriptor_t& sig, bool bi
282281 }
283282
284283 fwriter->AppendLine (" " ,2 );
284+
285+ if (sig.IsDoubleSig )
286+ {
287+ // this code only required be d-signals (floating point values based)
288+ // it placed additional signals to struct for conversion
289+ // to/from physical values. For non-simple and non-double signal
290+ // there is no necessity to create addition fields
291+ // @sigfloat_t must be typedefed by user (e.g. double / float)
292+ fwriter->AppendLine (PrintF (" #ifdef %s" , fdesc->usesigfloat_def .c_str ()));
293+
294+ fwriter->AppendLine (PrintF (" sigfloat_t %s_phys;" , sig.Name .c_str ()));
295+
296+ fwriter->AppendLine (PrintF (" #endif // %s" , fdesc->usesigfloat_def .c_str ()),2 );
297+
298+ }
285299}
286300
287301void CiMainGenerator::WriteUnpackBody (const CiExpr_t* sgs)
@@ -291,6 +305,28 @@ void CiMainGenerator::WriteUnpackBody(const CiExpr_t* sgs)
291305auto expr = sgs->to_signals [num];
292306
293307 fwriter->AppendLine (PrintF (" _m->%s = %s;" , sgs->msg .Signals [num].Name .c_str (), expr.c_str ()));
308+
309+ // print sigfloat conversion
310+ if (sgs->msg .Signals [num].IsDoubleSig )
311+ {
312+ fwriter->AppendLine (PrintF (" \n #ifdef %s" , fdesc->usesigfloat_def .c_str ()));
313+ fwriter->AppendLine (PrintF (" _m->%s_phys = (sigfloat_t)(%s_%s_fromS(_m->%s));" ,
314+ sgs->msg .Signals [num].Name .c_str (), fdesc->DRVNAME .c_str (),
315+ sgs->msg .Signals [num].Name .c_str (), sgs->msg .Signals [num].Name .c_str ()));
316+ fwriter->AppendLine (PrintF (" #endif // %s" , fdesc->usesigfloat_def .c_str ()),2 );
317+ }
318+
319+ else if (!sgs->msg .Signals [num].IsSimpleSig )
320+ {
321+ // print unpack conversion for non-simple and non-double signals
322+ // for this case conversion fromS is performed to signal itself
323+ // without (sigfloat_t) type casting
324+ fwriter->AppendLine (PrintF (" \n #ifdef %s" , fdesc->usesigfloat_def .c_str ()));
325+ fwriter->AppendLine (PrintF (" _m->%s = (%s_%s_fromS(_m->%s));" ,
326+ sgs->msg .Signals [num].Name .c_str (), fdesc->DRVNAME .c_str (),
327+ sgs->msg .Signals [num].Name .c_str (), sgs->msg .Signals [num].Name .c_str ()));
328+ fwriter->AppendLine (PrintF (" #endif // %s" , fdesc->usesigfloat_def .c_str ()),2 );
329+ }
294330 }
295331
296332 fwriter->AppendLine (" " );
@@ -323,9 +359,36 @@ void CiMainGenerator::WritePackStructBody(const CiExpr_t* sgs)
323359 fwriter->AppendLine (" {" );
324360
325361// pring array content clearin loop
326- fwriter->AppendLine (
327- PrintF (" uint8_t i; for (i = 0; (i < %s_DLC) && (i < 8); cframe->Data[i++] = 0);" ,
328- sgs->msg .Name .c_str ()),2 );
362+ fwriter->AppendLine (PrintF (" uint8_t i; for (i = 0; (i < %s_DLC) && (i < 8); cframe->Data[i++] = 0);" ,
363+ sgs->msg .Name .c_str ()),2 );
364+
365+ // first step is to put code for sigfloat conversion, before
366+ // sigint packing to bytes.
367+ fwriter->AppendLine (PrintF (" #ifdef %s" , fdesc->usesigfloat_def .c_str ()),2 );
368+
369+ for (size_t n =0 ; n < sgs->to_signals .size (); n++)
370+ {
371+ if (sgs->msg .Signals [n].IsSimpleSig ==false )
372+ {
373+ if (sgs->msg .Signals [n].IsDoubleSig )
374+ {
375+ // print toS from *_phys to original named sigint (integer duplicate of signal)
376+ fwriter->AppendLine (PrintF (" _m->%s = %s_%s_fromS(_m->%s_phys);" ,
377+ sgs->msg .Signals [n].Name .c_str (), fdesc->DRVNAME .c_str (),
378+ sgs->msg .Signals [n].Name .c_str (), sgs->msg .Signals [n].Name .c_str ()));
379+ }
380+ else
381+ {
382+ // print toS from original named signal to itself (because this signal
383+ // has enough space for scaling by factor and proper sign
384+ fwriter->AppendLine (PrintF (" _m->%s = %s_%s_fromS(_m->%s);" ,
385+ sgs->msg .Signals [n].Name .c_str (), fdesc->DRVNAME .c_str (),
386+ sgs->msg .Signals [n].Name .c_str (), sgs->msg .Signals [n].Name .c_str ()));
387+ }
388+ }
389+ }
390+
391+ fwriter->AppendLine (PrintF (" \n #endif // %s" , fdesc->usesigfloat_def .c_str ()),2 );
329392
330393for (size_t i =0 ; i < sgs->to_bytes .size (); i++)
331394 {
@@ -352,6 +415,34 @@ void CiMainGenerator::WritePackArrayBody(const CiExpr_t* sgs)
352415 fwriter->AppendLine (PrintF (" uint8_t i; for (i = 0; (i < %s_DLC) && (i < 8); _d[i++] = 0);" ,
353416 sgs->msg .Name .c_str ()),2 );
354417
418+ // first step is to put code for sigfloat conversion, before
419+ // sigint packing to bytes.
420+ fwriter->AppendLine (PrintF (" #ifdef %s" , fdesc->usesigfloat_def .c_str ()),2 );
421+
422+ for (size_t n =0 ; n < sgs->to_signals .size (); n++)
423+ {
424+ if (sgs->msg .Signals [n].IsSimpleSig ==false )
425+ {
426+ if (sgs->msg .Signals [n].IsDoubleSig )
427+ {
428+ // print toS from *_phys to original named sigint (integer duplicate of signal)
429+ fwriter->AppendLine (PrintF (" _m->%s = %s_%s_fromS(_m->%s_phys);" ,
430+ sgs->msg .Signals [n].Name .c_str (), fdesc->DRVNAME .c_str (),
431+ sgs->msg .Signals [n].Name .c_str (), sgs->msg .Signals [n].Name .c_str ()));
432+ }
433+ else
434+ {
435+ // print toS from original named signal to itself (because this signal
436+ // has enough space for scaling by factor and proper sign
437+ fwriter->AppendLine (PrintF (" _m->%s = %s_%s_fromS(_m->%s);" ,
438+ sgs->msg .Signals [n].Name .c_str (), fdesc->DRVNAME .c_str (),
439+ sgs->msg .Signals [n].Name .c_str (), sgs->msg .Signals [n].Name .c_str ()));
440+ }
441+ }
442+ }
443+
444+ fwriter->AppendLine (PrintF (" \n #endif // %s" , fdesc->usesigfloat_def .c_str ()),2 );
445+
355446for (size_t i =0 ; i < sgs->to_bytes .size (); i++)
356447 {
357448if (sgs->to_bytes [i].size () <2 )