当前位置: 首页>>代码示例>>Java>>正文


Java IIntInputStream类代码示例

本文整理汇总了Java中com.rapplogic.xbee.util.IIntInputStream的典型用法代码示例。如果您正苦于以下问题:Java IIntInputStream类的具体用法?Java IIntInputStream怎么用?Java IIntInputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IIntInputStream类属于com.rapplogic.xbee.util包,在下文中一共展示了IIntInputStream类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parse

import com.rapplogic.xbee.util.IIntInputStream; //导入依赖的package包/类
public void parse(IPacketParser parser) throws IOException {

		if (parser.getApiId() == ApiId.RX_16_IO_RESPONSE) {
			this.setSourceAddress(parser.parseAddress16());	
		} else {
			this.setSourceAddress(parser.parseAddress64());
		}	
		
		super.parseBase(parser);

		log.debug("this is a I/O sample!");
		// first byte is # of samples
		int sampleSize = parser.read("# I/O Samples");
		
		// create i/o samples array
		this.setSamples(new IoSample[sampleSize]);
		
		// channel indicator 1
		this.setChannelIndicator1(parser.read("Channel Indicator 1"));
		
		log.debug("channel indicator 1 is " + ByteUtils.formatByte(this.getChannelIndicator1()));
		
		// channel indicator 2 (dio)
		this.setChannelIndicator2(parser.read("Channel Indicator 2"));
		
		log.debug("channel indicator 2 is " + ByteUtils.formatByte(this.getChannelIndicator2()));	
		
		// collect each sample
		for (int i = 0; i < this.getSamples().length; i++) {
			
			log.debug("parsing sample " + (i + 1));
			
			IoSample sample = parseIoSample((IIntInputStream)parser);
			
			// attach sample to parent
			this.getSamples()[i] = sample;
		}		
	}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:39,代码来源:RxResponseIoSample.java

示例2: parse

import com.rapplogic.xbee.util.IIntInputStream; //导入依赖的package包/类
public void parse(IPacketParser parser) throws IOException {
	this.parseAddress(parser);
	this.parseOption(parser);
	this.parseIoSample((IIntInputStream)parser);
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:6,代码来源:ZNetRxIoSampleResponse.java

示例3: parseIoSample

import com.rapplogic.xbee.util.IIntInputStream; //导入依赖的package包/类
/**
 * This method is a bit non standard since it needs to parse an IO sample
 * from either a RX response or a Remote AT/Local AT response (IS).
 * 
 * @param ps
 * @throws IOException
 */
public void parseIoSample(IIntInputStream parser) throws IOException {
	// eat sample size.. always 1
	int size = parser.read("ZNet RX IO Sample Size");
	
	if (size != 1) {
		throw new XBeeParseException("Sample size is not supported if > 1 for ZNet I/O");
	}
	
	this.setDigitalChannelMaskMsb(parser.read("ZNet RX IO Sample Digital Mask 1"));
	this.setDigitalChannelMaskLsb(parser.read("ZNet RX IO Sample Digital Mask 2"));
	this.setAnalogChannelMask(parser.read("ZNet RX IO Sample Analog Channel Mask"));
	
	// zero out n/a bits
	this.analogChannelMask = this.analogChannelMask & 0x8f; //10001111
	// zero out all but bits 3-5
	// TODO apparent bug: channel mask on ZigBee Pro firmware has DIO10/P0 as enabled even though it's set to 01 (RSSI).  Digital value reports low. 
	this.digitalChannelMaskMsb = this.digitalChannelMaskMsb & 0x1c; //11100
			
	if (this.containsDigital()) {
		log.info("response contains digital data");
		// next two bytes are digital
		this.setDioMsb(parser.read("ZNet RX IO DIO MSB"));
		this.setDioLsb(parser.read("ZNet RX IO DIO LSB"));
	} else {
		log.info("response does not contain digital data");
	}
	
	// parse 10-bit analog values
	
	int enabledCount = 0;
	
	for (int i = 0; i < 4; i++) {
		if (this.isAnalogEnabled(i)) {
			log.info("response contains analog[" + i + "]");
			analog[i] = ByteUtils.parse10BitAnalog(parser, enabledCount);
			enabledCount++;
		}			
	}
	
	if (this.isSupplyVoltageEnabled()) {
		analog[SUPPLY_VOLTAGE_INDEX] = ByteUtils.parse10BitAnalog(parser, enabledCount);
		enabledCount++;
	}
	
	log.debug("There are " + analog + " analog inputs in this packet");
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:54,代码来源:ZNetRxIoSampleResponse.java

示例4: PacketParser

import com.rapplogic.xbee.util.IIntInputStream; //导入依赖的package包/类
public PacketParser(IIntInputStream in) {
	this.in = in;
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:4,代码来源:PacketParser.java

示例5: parseIoSample

import com.rapplogic.xbee.util.IIntInputStream; //导入依赖的package包/类
private IoSample parseIoSample(IIntInputStream parser) throws IOException {

		IoSample sample = new IoSample(this);
		
		// DIO 8 occupies the first bit of the adcHeader
		if (this.containsDigital()) {
			// at least one DIO line is active
			// next two bytes are DIO
			
			log.debug("Digital I/O was received");
			
			sample.setDioMsb(parser.read("DIO MSB"));
			sample.setDioLsb(parser.read("DIO LSB"));
		}
		
		// ADC is active if any of bits 2-7 are on
		if (this.containsAnalog()) {
			// adc is active
			// adc is 10 bits
			
			log.debug("Analog input was received");
			
			// 10-bit values are read two bytes per sample
			
			int analog = 0;
			
			// Analog inputs A0-A5 are bits 2-7 of the adcHeader
			
			if (this.isA0Enabled()) {
				sample.setAnalog0(ByteUtils.parse10BitAnalog(parser, analog));
				analog++;				
			}

			if (this.isA1Enabled()) {
				sample.setAnalog1(ByteUtils.parse10BitAnalog(parser, analog));
				analog++;
			}

			if (this.isA2Enabled()) {
				sample.setAnalog2(ByteUtils.parse10BitAnalog(parser, analog));
				analog++;
			}

			if (this.isA3Enabled()) {
				sample.setAnalog3(ByteUtils.parse10BitAnalog(parser, analog));
				analog++;
			}

			if (this.isA4Enabled()) {
				sample.setAnalog4(ByteUtils.parse10BitAnalog(parser, analog));
				analog++;
			}
			
			if (this.isA5Enabled()) {
				sample.setAnalog5(ByteUtils.parse10BitAnalog(parser, analog));
				analog++;
			}
			
			log.debug("There are " + analog + " analog inputs turned on");
		}
		
		return sample;
	}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:64,代码来源:RxResponseIoSample.java


注:本文中的com.rapplogic.xbee.util.IIntInputStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。