template.SlidingCountTemplate.vsl Maven / Gradle / Ivy
## Velocity Template.
package ${functionPackage};
#foreach( $import in $imports)
import $import;
#end
/**
*
* @author greg
*/
public class ${functionClass} extends CountSlidingBuffer{
public ${sourceClass} ${input};
public ${outputClass}[] buffer;
public Object startTrigger;
public Object resetNotifier;
@OnParentUpdate("startTrigger")
public void startTrigger(Object startTrigger) {
publish = true;
}
@OnParentUpdate("resetNotifier")
public void reset(Object resetNotifier) {
init();
}
@OnParentUpdate("${input}")
public void OnSourceUpdate(Object source) {
writePointer++;
if (writePointer >= bufferSize) {
writePointer = 0;
}
lastPublish++;
if (lastPublish >= windowSpacing) {
lastPublish = 0;
publish = true;
}
buffer[writePointer] = ${sourceMethod};
}
@OnEvent
public boolean OnEvent() {
return publish;
}
@OnEventComplete
public void afterEvent() {
publish = false;
}
@Override
public ${outputClass}[] getBuffer() {
return buffer;
}
@Initialise
public void init() {
//TODo handle start trigger properly
publish = false; //startTrigger == null;
writePointer = 0;
if(buffer == null)
buffer = new ${outputClass}[bufferSize];
lastPublish = 0;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy