package dea.monitor.checker;

import java.awt.image.BufferedImage;
import java.util.Date;
import java.util.GregorianCalendar;

import dea.monitor.db.DBInterface;

public interface CheckItemI extends Runnable {

	/**
	 * load the properties for an item from the DB id dbi is set otherwise from
	 * property files
	 * 
	 * @param bundleName
	 * @throws ClassNotFoundException
	 * @throws InstantiationException
	 * @throws IllegalAccessException
	 */
	void loadBundle(String bundleName) throws ClassNotFoundException, InstantiationException, IllegalAccessException;

	/**
	 * Is check running
	 * 
	 * @return
	 */
	boolean isRunning();

	/**
	 * Run check in a Thread
	 * 
	 * @return
	 */
	Thread background();

	/**
	 * Stop a check from running
	 * 
	 * @return
	 */
	boolean killThread();

	/**
	 * Get name of Check item
	 * 
	 * @return
	 */
	String getName();

	/**
	 * Get time of next run
	 * 
	 * @return
	 */
	GregorianCalendar getNextRun();

	/**
	 * Set time of next run
	 * 
	 * @param nextRun
	 */
	void setNextRun(GregorianCalendar nextRun);

	/**
	 * Get when last successfully ran check
	 * 
	 * @return
	 */
	Date getLastOK();

	/**
	 * Was last check successful
	 * 
	 * @return
	 */
	boolean isLastRunOK();

	/**
	 * If true this check displays as multiple items.
	 * 
	 * @return
	 */
	boolean isMutliCheck();

	/**
	 * Get cause to last check failure
	 * 
	 * @return
	 */
	String getErrStr();

	/**
	 * Set cause to last check failure
	 * 
	 * @param errStr
	 */
	void setErrStr(String errStr);

	/**
	 * Get extra data stored to help with debugging
	 * 
	 * @return
	 */
	String getDetails();

	/**
	 * Set extra data stored to help with debugging
	 * 
	 * @param details
	 */
	void setDetails(String details);

	/**
	 * Get response content type of last URL check
	 * 
	 * @return
	 */
	String getContentType();

	/**
	 * If the response content type was image this returns that image.
	 * 
	 * @return
	 */
	BufferedImage getSavedImg();

	/**
	 * Get time to wait between checks in seconds Set from wait property
	 * 
	 * @return
	 */
	int getWait();

	/**
	 * Get the description property
	 * 
	 * @return
	 */
	public String getDescription();

	/**
	 * Get the region property. Used to group items in GUI
	 * 
	 * @return
	 */
	String getRegion();

	/**
	 * Give DB connection to use instead of props files
	 * 
	 * @param dbi
	 */
	void setDbi(DBInterface dbi);

	// common broadcast codes
	float BC_OFFLINE = 0f;
	float BC_CONNECTED = 1f;
	float BC_NOT_CONNECTED = 2f;
	float BC_TRIGGERED = 3f;
	float BC_RECORDING = 4f;
	float BC_MOTION = 5f;
	float BC_PAUSED = 6f;
	float BC_HIDDEN = 7f;
	float BC_TEMPFULL = 8f;
	float BC_NO_SIGNAL = 9f;
	float BC_DISABLED = 10f;
	float BC_YELLOW = 10f;

	float BC_SSH_ERROR = 20f;
	
	float BC_EXCEPTION = 100f;
	// 200-507 See HttpStatus
	float BC_OK = 200f;
	float BC_LOGIN_FAILED = 901f;
	float BC_CONTENT_MISSING = 902f;
	float BC_CONTENT_BAD = 903f;
	float BC_CONTENT_OLD = 904f;
	float BC_FAIL_FOUND = 905f;
}

@@ -2588,24 +2588,46 @@
 LINE = 0f;%0D%0A
+%09// device connected%0D%0A
 %09float BC_CO
@@ -2637,24 +2637,50 @@
 CTED = 1f;%0D%0A
+%09// device not connected%0D%0A
 %09float BC_NO
@@ -2694,24 +2694,55 @@
 CTED = 2f;%0D%0A
+%09// Camera has been triggered%0D%0A
 %09float BC_TR
@@ -2752,24 +2752,49 @@
 ERED = 3f;%0D%0A
+%09// Camera is recording%0D%0A
 %09float BC_RE
@@ -2804,24 +2804,53 @@
 DING = 4f;%0D%0A
+%09// Camera detecting motion%0D%0A
 %09float BC_MO
@@ -2857,24 +2857,46 @@
 TION = 5f;%0D%0A
+%09// Camera is paused%0D%0A
 %09float BC_PA
@@ -2903,24 +2903,46 @@
 USED = 6f;%0D%0A
+%09// camera is hidden%0D%0A
 %09float BC_HI
@@ -2949,24 +2949,44 @@
 DDEN = 7f;%0D%0A
+%09// temp area full%0D%0A
 %09float BC_TE
@@ -2995,24 +2995,50 @@
 FULL = 8f;%0D%0A
+%09// camera has no signal%0D%0A
 %09float BC_NO
@@ -3048,24 +3048,48 @@
 GNAL = 9f;%0D%0A
+%09// camera is disabled%0D%0A
 %09float BC_DI
@@ -3099,24 +3099,72 @@
 LED = 10f;%0D%0A
+%09//when motion detection is paused or disabled%0D%0A
 %09float BC_YE
@@ -3175,15 +3175,30 @@
  = 1
-0
+1
 f;%0D%0A%0D%0A
+%09// SSH error%0D%0A
 %09flo
@@ -3249,24 +3249,27 @@
 ON = 100f;%0D%0A
+%09%0D%0A
 %09// 200-507 
@@ -3302,24 +3302,66 @@
 OK = 200f;%0D%0A
+%09%0D%0A%09// 900 - 999 MyMonitor checker error%0D%0A
 %09float BC_LO

fix typo and add comments