Hi Claes, Thank you for replying. I would like to get the timer working in the other ASup due to the revisions I made to the DetectText and MoreText. Shown below is the ASup code that I modified.
I also added to new variables(DetectTime_t, DoneTime_t) to the pwr_sClass_ASup object structure.
This seems to be working but may not be the best solution.
Can you please comment on a better way to complete this task.
Why is the original timer not working?
static void aSup_exec (sSupActive *sp)
{
pwr_sClass_ASup *o = (pwr_sClass_ASup *) sp->op;
pwr_tFloat32 In = *(pwr_tFloat32 *) sp->actualValue;
//char catstr001[160]="";
//printf("pwr_sClass_ASup In = %.3f\n", In);
if ((o->High && In <= o->CtrlLimit - o->Hysteres) || (!o->High && In >= o->CtrlLimit + o->Hysteres))
{
if (o->Action) o->Action = FALSE;
if (o->ReturnCheck) {
time_GetTime(&o->ReturnTime);
o->ReturnCheck = FALSE;
o->ReturnSend = TRUE;
}
if (o->AlarmCheck && !o->DetectCheck) {
o->TimerFlag = FALSE;
o->DetectCheck = TRUE;
}
} else if ((o->High && In > o->CtrlLimit) || (!o->High && In < o->CtrlLimit)) {
if (!o->Action) {
o->Action = TRUE;
}
if (o->Suppressed) {
if (o->ReturnCheck) {
time_GetTime( &o->ReturnTime);
o->ReturnCheck = FALSE;
o->ReturnSend = TRUE;
}
else if (o->DetectSend)
o->DetectSend = FALSE;
}
if (o->AlarmCheck && o->DetectOn && !o->Blocked && !o->Suppressed) {
if (o->DetectCheck) {
o->ActualValue = In;
o->DetectTime_t=time(NULL);
o->DoneTime_t = o->DetectTime_t + (long int)o->TimerTime;
printf("DetectTime_t:%ld DoneTime_t:%ld\n",o->DetectTime_t, (long int)o->DoneTime_t);
timerIn(sp, (sTimer *)&o->TimerFlag);
time_GetTime(&o->DetectTime);
o->DetectCheck = FALSE;
}
// if (!o->TimerFlag) {
if (time(NULL) > o->DoneTime_t) {
o->DetectSend = TRUE;
o->ReturnCheck = TRUE;
o->Acked = FALSE;
o->AlarmCheck = FALSE;
}
}
}
// cat here
if(o->Action && !o->Acked) {
int len_mt, len_dt;
len_mt=strlen(o->MoreText);
len_dt=strlen(o->DetectText);
// put a NULL at the end of DetectText
o->DetectText[len_dt-len_mt]=0x00;
sprintf(o->MoreText, " %.1f ", In);
//printf("Asup In %.1f\n", In);
strncat(o->DetectText, o->MoreText, strlen(o->MoreText));
}
}