The logic shown below is executed at 50Hz max over several minutes, and I need to turbocharge. Would "switch/case" be faster?
(Since this code is repetitive, I was thinking of auto-generating an equivalent code segment minus the burdensome logic tree. But this may be overkill.)
Thanks,
-Bob
###################################################
if ( match(DF,/[Uu]nsigned/) > 0 ) {
if ( match(PrFormat[iv],/[Zz]/) > 0 )
printf ("\047%s\047", substr(hex2bin(DataString[iv]),SB,FL) );
else
printf ("%" PF, hex2uint( hex2bin(DataString[iv],SB,FL) ) * SC );
}
else if ( match(DF,/[Tt]wos_/) > 0 ) {
if ( MUXName[iv] == "EGI06BC1600"
printf ("%" PF, cap2float(DataString[iv]) );
else
printf ("%" PF, hex2int( substr(DataString[iv],SB,FL) ) * SC) ;
}
else if ( match(DF,/IEEE_[Ff]loat/) > 0) {
if (NW == 2)
printf ("%" PF, dword_to_float(DataString[iv]) * SC ) ;
else
printf ("%" PF, qword_to_double(DataString[iv]) * SC ) ;
}
else {
#Assume that the data format is ASCII...
printf ("%s", hex2ascii( substr(DataString[iv],SB,FL) ) );
}
(Since this code is repetitive, I was thinking of auto-generating an equivalent code segment minus the burdensome logic tree. But this may be overkill.)
Thanks,
-Bob
###################################################
if ( match(DF,/[Uu]nsigned/) > 0 ) {
if ( match(PrFormat[iv],/[Zz]/) > 0 )
printf ("\047%s\047", substr(hex2bin(DataString[iv]),SB,FL) );
else
printf ("%" PF, hex2uint( hex2bin(DataString[iv],SB,FL) ) * SC );
}
else if ( match(DF,/[Tt]wos_/) > 0 ) {
if ( MUXName[iv] == "EGI06BC1600"
printf ("%" PF, cap2float(DataString[iv]) );
else
printf ("%" PF, hex2int( substr(DataString[iv],SB,FL) ) * SC) ;
}
else if ( match(DF,/IEEE_[Ff]loat/) > 0) {
if (NW == 2)
printf ("%" PF, dword_to_float(DataString[iv]) * SC ) ;
else
printf ("%" PF, qword_to_double(DataString[iv]) * SC ) ;
}
else {
#Assume that the data format is ASCII...
printf ("%s", hex2ascii( substr(DataString[iv],SB,FL) ) );
}