JNIOR嵌入式系统开发

最近项目开发,使用了JNIOR Series 4,现将JNIOR开发总结如下:

 

1、常用的官方软件、文档地址:

http://www.integpg.com/support/jnior/

http://www.jnior.com/category/java-code-sample/

http://jnior.com/download/janosruntime_1-7-1-jar/

 

2、java测试代码

编译此部分的代码,将.class文件或可执行的jar文件通过FTP放入JNIOR的文件系统里,使用java命令运行。



import java.io.IOException;

import com.integpg.system.JANOS;
public class WriteOutputs {
    public static void main(String[] args) throws IOException, InterruptedException {
    	
    	System.out.println("hello Alen");
    	JANOS.setOutputRelay(4,true);
    	 Thread.sleep(1000);
    	 JANOS.setOutputRelay(4,false);
    	 Thread.sleep(1000);
    	 
    	 JANOS.setOutputStates(6, 6);//bit1,bit2 open
    	 Thread.sleep(1000);
    	 JANOS.setOutputStates(0, 6);//bit1,bit2 close
    	 Thread.sleep(1000);
    	
    	// to get the states of the outputs use the JANOS class and the getOutputStates method
        int outputStates = JANOS.getOutputStates();
        //print the Output States through telnet (console) connection.
        System.out.println("Output States are: " + outputStates);
        //Pulse 8 Relay Outputs On for 5 seconds (5000 milliseconds) after which outputs will return to previous state.
        //All channels (1111 1111b)
        try {
			JANOS.setOutputPulsed(255, 255, 5000);
			System.out.println("JANOS.setOutputPulsed(255, 255, 5000);");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        //Sleep 10 seconds to so that there is a noticable difference between on and off states.
        try {
            Thread.sleep(10000);
            System.out.println("Thread.sleep(10000);");
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        }
        int counter = 0;
        while(counter<5){
        //Pulse Channel 5 Relay Output On for 5 seconds (5000 milliseconds) after which output will return to previous state.
        //Channels   8765 4321
        //Channel 5 (0001 0000b)
        try {
			JANOS.setOutputPulsed(8, 8, 5000);
			System.out.println("JANOS.setOutputPulsed(8, 8, 5000);");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
            try {
                Thread.sleep(10000);
            } catch (InterruptedException ex) {
                ex.printStackTrace();
            }
            counter++;
            System.out.println("Counter: " + counter);
        }
    }
}

注意:编译此代码使用到的jar包是 JanosClasses.jar , 此文件可从JNIOR的etc目录下拷贝出来。

 

你可能感兴趣的:(嵌入式应用程序)