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目录下拷贝出来。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Alen.Wang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值