Programming Examples &
Sample Code
|
| G-6. Sample Code for control PCI 8 Photo/8
Relay Card |
Date : 2003, Feb. 27
|
|
Program idea:
|
|
| motion detect |
|
If sniff out image is move start alarm
|
|
****** Sample Code for control PCI 4 Channels Video Capture Card
*****
|
|
import java.io.*;
|
|
import com.decision.rp.user.Adaptlet;
|
|
public class CaptureCompare extends Adaptlet implements Runnable
|
|
{
|
|
private Thread mainThread = null;
|
|
private byte[] jpgold=null;
|
|
//Start the adaptlet.
|
|
public void start()
|
|
{
|
|
//Create the thread.
|
|
this.mainThread = new Thread(this);
|
|
//Start the thread, that will invoke the run() method.
|
|
this.mainThread.start();
|
|
//To get the start-image size.
|
|
jpgold = this.getJPEGImage(0,80);
|
|
}
|
|
//Stop the adaptlet.
|
|
public void stop()
|
|
{
|
|
this.mainThread = null;
|
|
| } |
|
//If the state of the sensor is change, this function will be called.
|
|
public void valueChanged(int card, int port, int line, int state)
|
|
{
|
|
| } |
|
//Run thread.
|
|
public void run()
|
|
{
|
|
while (this.mainThread != null)
|
|
{
|
|
| //To get now-image size. |
|
byte[] jpg = this.getJPEGImage(0,80);
|
|
//When jpg is more or lower 1000 bytes then jpgold, open the line
0
|
|
//of Industrial card's port0.
|
|
if ((jpgold != null) && (Math.abs(jpgold.length-jpg.length)>1000))
|
|
{
|
|
this.set(INDUSTRIAL_CARD,0,0,1);
|
|
}
|
|
try { Thread.sleep(1000); } catch (InterruptedException ie) {}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|