ok so I was able to to achieve what I wanted with the following its hacky but if works. How do I go about terminating this alarm ? I want to terminate the alarm as soon as the time expires.
ts = ReadPersistentStorage("ts_".$node->name);
if(ts == NULL){
/* create initial timestamp and event*/
WritePersistentStorage("ts_".$node->name,$event->timestamp);
WritePersistentStorage($node->name,1);
return;
}
/* if within time range of 10min check storage */
if (time() - ts <=600){
events = ReadPersistentStorage($node->name);
WritePersistentStorage($node->name,events+1);
if (events!=NULL ){
if (events >=5){
return true;
}
}
}else{
/* if time is over 10min reset storage values for timestamp and event*/
WritePersistentStorage($node->name, NULL);
WritePersistentStorage("ts_".$node->name, NULL);
}
ts = ReadPersistentStorage("ts_".$node->name);
if(ts == NULL){
/* create initial timestamp and event*/
WritePersistentStorage("ts_".$node->name,$event->timestamp);
WritePersistentStorage($node->name,1);
return;
}
/* if within time range of 10min check storage */
if (time() - ts <=600){
events = ReadPersistentStorage($node->name);
WritePersistentStorage($node->name,events+1);
if (events!=NULL ){
if (events >=5){
return true;
}
}
}else{
/* if time is over 10min reset storage values for timestamp and event*/
WritePersistentStorage($node->name, NULL);
WritePersistentStorage("ts_".$node->name, NULL);
}