<commit_before>package com.ociweb.device.testApp;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.ociweb.iot.maker.FogRuntime;
import com.ociweb.iot.maker.Hardware;
import com.ociweb.iot.maker.FogApp;
import com.ociweb.iot.maker.ImageListener;
import com.ociweb.pronghorn.iot.schema.ImageSchema;
import com.ociweb.pronghorn.pipe.DataInputBlobReader;

/**
 * Simple Pi image capture test.
 *
 * @author <NAME> [<EMAIL>]
 */
public class PiCamTest implements FogApp {

    private final List<File> images = new ArrayList<>();

    public static void main( String[] args) {
        FogRuntime.run(new PiCamTest());
    }

    @Override
    public void declareConnections(Hardware hardware) {
        hardware.setImageTriggerRate(30);
    }

    @Override
    public void declareBehavior(FogRuntime runtime) {
        runtime.addImageListener(new ImageListener() {

            FileOutputStream workingFile = null;

            @Override
            public void onFrameStart(int width, int height, long timestamp) {

                // Close existing file if present.
                if (workingFile != null) {
                    try {
                        System.out.println("Captured full image to disk.");
                        workingFile.flush();
                        workingFile.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }

                // Clean existing files if there are many.
                if (images.size() > 50) {
                    File f = images.get(0);
                    images.remove(0);
                    f.delete();
                }

                // Open new file.
                try {
                    File newWorkingFile = new File("image-" + timestamp + ".raw");
                    newWorkingFile.createNewFile();
                    images.add(newWorkingFile);
                    workingFile = new FileOutputStream(newWorkingFile);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onFrameRow(byte[] frameRowBytes) {
                try {
                    workingFile.write(frameRowBytes);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
    }
}
<commit_msg>Add debug messages.<commit_after>package com.ociweb.device.testApp;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.ociweb.iot.maker.FogRuntime;
import com.ociweb.iot.maker.Hardware;
import com.ociweb.iot.maker.FogApp;
import com.ociweb.iot.maker.ImageListener;
import com.ociweb.pronghorn.iot.schema.ImageSchema;
import com.ociweb.pronghorn.pipe.DataInputBlobReader;

/**
 * Simple Pi image capture test.
 *
 * @author <NAME> [<EMAIL>]
 */
public class PiCamTest implements FogApp {

    private final List<File> images = new ArrayList<>();

    public static void main( String[] args) {
        FogRuntime.run(new PiCamTest());
    }

    @Override
    public void declareConnections(Hardware hardware) {
        hardware.setImageTriggerRate(30);
    }

    @Override
    public void declareBehavior(FogRuntime runtime) {
        runtime.addImageListener(new ImageListener() {

            FileOutputStream workingFile = null;

            @Override
            public void onFrameStart(int width, int height, long timestamp) {

                // Close existing file if present.
                if (workingFile != null) {
                    try {
                        System.out.println("Captured full image to disk.");
                        workingFile.flush();
                        workingFile.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }

                // Clean existing files if there are many.
                if (images.size() > 50) {
                    File f = images.get(0);
                    images.remove(0);
                    f.delete();
                }

                // Open new file.
                try {
                    File newWorkingFile = new File("image-" + timestamp + ".raw");
                    newWorkingFile.createNewFile();
                    images.add(newWorkingFile);
                    workingFile = new FileOutputStream(newWorkingFile);
                    System.out.printf("Began new working file for image W%dxH%d\n", width, height);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onFrameRow(byte[] frameRowBytes) {
                try {
                    workingFile.write(frameRowBytes);
                    System.out.println("Received frame row.");
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
    }
}

{'fraction_non_alphanumeric': 0.0967616831491177, 'fraction_numerical': 0.002326934264107039, 'mean_word_length': 1.5234833659491194, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7316877', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1238, 'n_words': 296}