package sensicamJNI;

import java.io.IOException;
import java.nio.ByteBuffer;

import otherSupport.SettingsManager;

/** JNI calls to linux sensicam SDK */

public class Sensicam {
	static {
		//System.load("/work/minerva/code/Sensicam/jni/sensicamJNI.so");
		//System.load("/home/ethicsMinerva/code2/Sensicam/jni/sensicamJNI.so");
		//System.loadLibrary("sensicamJNI");
		//System.load(System.getProperty("user.dir") + "/../Sensicam/jni/sensicamJNI.so");
		System.load(SettingsManager.defaultGlobal().getPathProperty("sensicam.jniLibPath", "/usr/lib/sensicamJNI.so"));
	}
	
	/*********** sencaml.h **************/
	
	public static native long[] sen_initboard(int board);	
	public static native int sen_closeboard(long hdriver);
	public static native void sen_enable_message_log(int msg_lev, String fileName);
	public static native void sen_set_syslog_facility(int msg_lev);
	public static native int sen_setup_camera(long hdriver);
	public static native int sen_get_cam_param(long hdriver, SencamDef.cam_param param);
	public static native int sen_set_coc(long hdriver,
			int mode,    int trig,
            int roixmin, int roixmax,
            int roiymin, int roiymax,
            int hbin,    int vbin,
            String timevalues);
	
	public static native int[] sen_getsizes(long hdriver);
	public static native int[] sen_allocate_buffer(long hdriver, int bufnr, int size);

	public static native int sen_free_buffer(long hdriver, int bufnr);

	public static native int sen_run_coc(long hdriver,int mode);
	public static native int sen_stop_coc(long hdriver,int mode);
	public static native int sen_get_cam_values(long hdriver, SencamDef.cam_values val);
	public static native int sen_get_buffer_status(long hdriver, int bufnr, int mode, SenbufDev.DEVBUF stat, int len);
	public static native int sen_copy_buffer(long hdriver, int bufnr, ByteBuffer data, int size, int offset);
	public static native int sen_add_buffer_to_list(long hdriver, int bufnr, int size, int offset, int data);
	public static native int sen_remove_buffer_from_list(long hdriver, int bufnr);
	public static native int sen_set_buffer_event(long hdriver, int bufnr, int mode);
	
	public static native int select_with_timeout(long hDriver, double timeout);

	/*SEN_BUF_STAT_WRITE_DONE
	SEN_BUF_STAT_ERROR
	SEN_BUF_STAT_QUEUED
	*/
}
