Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: ASup TimerCount not counting down

ASup TimerCount not counting down 5 years 5 months ago #9967

  • barnes
  • barnes's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 92
  • Karma: 0
When I have TimerTime set to 10 seconds no alarms are displayed. The timer does not seem to be working. Maybe I have it set up wrong??


When the alarm happens the TimerFlag is set to TRUE and the TimerCount=TimerTime but nothing happens.


When I set the TimerTime back to 0 everything works fine.
The administrator has disabled public write access.

ASup TimerCount not counting down 5 years 5 months ago #9971

  • claes
  • claes's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 3178
  • Thank you received: 502
  • Karma: 133
Create the ASup in a plcpgm if you are using the timer.

/Claes
Last Edit: 5 years 5 months ago by claes.
The administrator has disabled public write access.

ASup TimerCount not counting down 5 years 5 months ago #9976

  • barnes
  • barnes's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 92
  • Karma: 0
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));
}

}
The administrator has disabled public write access.

ASup TimerCount not counting down 5 years 5 months ago #9982

  • barnes
  • barnes's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 92
  • Karma: 0
Here is the working aSup_exe function in rt_emon.c, TimerFlag is set and TimerCount counts down.




static void aSup_exec (sSupActive *sp)
{
pwr_sClass_ASup *o = (pwr_sClass_ASup *) sp->op;
pwr_tFloat32 In = *(pwr_tFloat32 *) sp->actualValue;


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);
// bbb
// timerIn(sp, (sTimer *)&o->TimerFlag);

o->TimerFlag=TRUE;
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;
o->TimerFlag=FALSE;
} else {
o->TimerCount = o->DoneTime_t - time(NULL);
}
}
}

// cat here
// bbb
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));
}



}
The administrator has disabled public write access.

ASup TimerCount not counting down 5 years 5 months ago #9983

  • barnes
  • barnes's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 92
  • Karma: 0
I would like to default all ASup object to a timer value of 10 seconds.

Where are the default values set for the ASup objects?
The administrator has disabled public write access.

ASup TimerCount not counting down 5 years 5 months ago #9992

  • claes
  • claes's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 3178
  • Thank you received: 502
  • Karma: 133
Template values can be set in file named $pwrp_db/wb.wb_load with this syntax
!
! localWB volume
! This volume contains template objects.
!
Volume localWb pwr_eClass_WorkBenchVolume 254.254.254.252
  Object Templates $PlantHier	
    Object ASup ASup
      Body RtBody
        Attr TimerTime = 20
      EndBody
    EndObject
  EndObject
EndVolume

/Claes
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Time to create page: 9.195 seconds