Simple Source Plus

Simple Source+

SimpleSourcePlus.java is a class that extends the SimpleSource giving it additional methods that allow you to quickly add additional data types (you can still add these types manually in the SimpleSource via binary puts) but requires libraries such as java.awt that are unsupported on certain devices such as android.

Currently it provides a way to quickly put images.

Time Stamped Image Source+

This source uses the SimpleSourcePlus.java class, utilizing the put(String, BufferedImage) overloaded method to place an image into DataTurbine. The source also time stamps the data by specifying the time as a parameter to the put command.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.rbnb.sapi.SAPIException;
public class TimeStampedImage {
    
    public static void main(String[] args) throws SAPIException, IOException {
        
        //Unix Timestamp in seconds
        double time = 1303347600;
         
        SimpleSourcePlus src = new SimpleSourcePlus("CoralCam");
        src.addChannel("temp");
        src.addChannel("img", SimpleSource.MIME_JPG);
        
        src.put("temp", 32.1, time);
        
        //Read Image
        BufferedImage img = ImageIO.read( new File("path/to/file.jpg"));
        src.put("img", img, time);
        
        src.flush();
    }
}

Note: By utilizing the SimpleSourcePlus, the source now relies on the java.awt core library. This library is found on most systems but is not compatible with certain Java Virtual Machines such as Android OS. This should not be an issue for most cases, but just something to be aware of. You can still include images into DataTurbine using the basic SimpleSource class translating the image into binary data, and calling the put method specifying a byte[].

Open Source DataTurbine Initiative © 2017 Frontier Theme