Hi guys
I am looking to understanding CTimeHandler in FORTE, but I have two question:
1- What is the meaning of FORTE_TIME_BASE_UNITS_PER_SECOND it shows what ?
2- What is the functionality of below function ? why we have this condition (MILISECONDS_PER_SECOND < FORTE_TIME_BASE_UNITS_PER_SECOND) over here?
void CIEC_TIME::setFromMiliSeconds(TValueType pa_nValue){
#if MILISECONDS_PER_SECOND < FORTE_TIME_BASE_UNITS_PER_SECOND this = pa_nValue * (FORTE_TIME_BASE_UNITS_PER_SECOND / MILISECONDS_PER_SECOND);
#else this = pa_nValue / (pa_nValue / FORTE_TIME_BASE_UNITS_PER_SECOND);
#endif
}
True body make sense but False body dose not make sense ...!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
ad 1) FORTE_TIME_BASE_UNITS_PER_SECOND defines the time base for the values stored in the TIME data type. IEC 61131-3 does not define the accuracy of TIME and with the that value you can define it for your platform. Per default the value is 1 000 000 000 which means that the base unit is 1ns.
ad 2) the function takes a time in miliseconds and transforms it to the representation of the TIME data type. The ifdef is needed to keep numeric stability. However as you noted the #else part makes no sense. If you look at the other functions around it you can see that. In cset [forte:958c76] you can find a fix.
Hi guys
I am looking to understanding CTimeHandler in FORTE, but I have two question:
1- What is the meaning of FORTE_TIME_BASE_UNITS_PER_SECOND it shows what ?
2- What is the functionality of below function ? why we have this condition (MILISECONDS_PER_SECOND < FORTE_TIME_BASE_UNITS_PER_SECOND) over here?
void CIEC_TIME::setFromMiliSeconds(TValueType pa_nValue){
#if MILISECONDS_PER_SECOND < FORTE_TIME_BASE_UNITS_PER_SECOND
this = pa_nValue * (FORTE_TIME_BASE_UNITS_PER_SECOND / MILISECONDS_PER_SECOND);
#else
this = pa_nValue / (pa_nValue / FORTE_TIME_BASE_UNITS_PER_SECOND);
#endif
}
True body make sense but False body dose not make sense ...!
Hi Aydin,
ad 1) FORTE_TIME_BASE_UNITS_PER_SECOND defines the time base for the values stored in the TIME data type. IEC 61131-3 does not define the accuracy of TIME and with the that value you can define it for your platform. Per default the value is 1 000 000 000 which means that the base unit is 1ns.
ad 2) the function takes a time in miliseconds and transforms it to the representation of the TIME data type. The ifdef is needed to keep numeric stability. However as you noted the #else part makes no sense. If you look at the other functions around it you can see that. In cset [forte:958c76] you can find a fix.
Thanks a lot for reporting this issue.
Related
Commit: [958c76]