How to write formula functions - diirt/diirt GitHub Wiki

The simplest way to learn how to write a formula function is to look at the implementation of the ones already provided in the formula package.

Each package (e.g. array, math, vnumber, ...) provides a set of functions. Each function can be implemented as an inner class, a package private class or a public class. The function set must be a registered extension using the ServiceLoader pattern. The pom.xml shows how.

Types of functions

The first step is to determine which kind of function you are implementing and choose the appropriate class to implement. Choose between these options, and refers to the examples and javadocs for more details.

When implementing a function, you should keep in mind null values, alarm conditions, timestamp, metadata and, in case of stateful functions, cleanup.