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


Java Port类代码示例

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


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

示例1: analogEvent

import com.ociweb.iot.maker.Port; //导入依赖的package包/类
@Override
public void analogEvent(Port port, long time, long durationMillis, int average, int value) {

	if (value>fullTank) {
		logger.trace("check equipment, tank {} is deeper than expected {} ",value,fullTank);
		value = fullTank;//default value for the error case
	}

	//sample must be stable for 2 seconds before we consider it safe for use
	if (durationMillis > 2000 && (value!=lastValue)) {

		int volumeCM = computeVolumeCM2(value);

		commandChannel.publishTopic(topic, w->{
			w.writeLong(time); //local time, may be off, do check the os
			w.writeInt(volumeCM);
			w.writeUTF(fuelName);
		});
		lastValue = value;
	}

}
 
开发者ID:oci-pronghorn,项目名称:FogLight-Examples,代码行数:23,代码来源:TankMonitor.java

示例2: commonDigitalEventProcessing

import com.ociweb.iot.maker.Port; //导入依赖的package包/类
protected void commonDigitalEventProcessing(Port port, long time, int value, DigitalListenerBase dListener) {
	
	if (isIncluded(port, includedPorts) && isNotExcluded(port, excludedPorts)) {

		if (sendEveryDigitalValue[port.port]) {
			dListener.digitalEvent(port, time, 0==lastDigitalTimes[port.port] ? -1 : time-lastDigitalTimes[port.port], value);				
			if(value!=lastDigitalValues[port.port]){  
				lastDigitalValues[port.port] = value;
		    	lastDigitalTimes[port.port] = time;
			}
			
		} else {			
			if(value!=lastDigitalValues[port.port]){  
				dListener.digitalEvent(port, time, 0==lastDigitalTimes[port.port] ? -1 : time-lastDigitalTimes[port.port], value);
			    lastDigitalValues[port.port] = value;
			    lastDigitalTimes[port.port] = time;
			}
		}
	}
}
 
开发者ID:oci-pronghorn,项目名称:FogLight,代码行数:21,代码来源:ReactiveIoTListenerStage.java

示例3: connect

import com.ociweb.iot.maker.Port; //导入依赖的package包/类
@Override
public Hardware connect(ADIODevice t, Port port, int customRateMS, int customAvgWindowMS, boolean everyValue) {
	
	int portsLeft = t.pinsUsed();

	while (--portsLeft >= 0){
		deviceOnPort[port.ordinal()] = t;

		if (0 != (port.mask&Port.IS_ANALOG)) {
			internalConnectAnalog(t, port.port, customRateMS, customAvgWindowMS, everyValue);
		}
		else if (0 != (port.mask&Port.IS_DIGITAL)) {
			internalConnectDigital(t, port.port, customRateMS, customAvgWindowMS, everyValue);
		}
		port = Port.nextPort(port);
	}
	return this;
}
 
开发者ID:oci-pronghorn,项目名称:FogLight,代码行数:19,代码来源:HardwareImpl.java

示例4: blockUntil

import com.ociweb.iot.maker.Port; //导入依赖的package包/类
@Override
public boolean blockUntil(Port port, long time) {
	assert((0 != (initFeatures & PIN_WRITER))) : "CommandChannel must be created with PIN_WRITER flag";
    assert(enterBlockOk()) : "Concurrent usage error, ensure this never called concurrently";
    try {
        if (goHasRoom() &&  PipeWriter.tryWriteFragment(pinOutput, GroveRequestSchema.MSG_BLOCKCONNECTIONUNTIL_221)) {

            PipeWriter.writeInt(pinOutput, GroveRequestSchema.MSG_BLOCKCONNECTIONUNTIL_221_FIELD_CONNECTOR_111, port.port);
            PipeWriter.writeLong(pinOutput, GroveRequestSchema.MSG_BLOCKCONNECTIONUNTIL_221_FIELD_TIMEMS_114, time);
            PipeWriter.publishWrites(pinOutput);
            
            int count = 1;
            builder.releasePinOutTraffic(count,this);
         
            return true;
        } else {
            return false;
        }

    } finally {
        assert(exitBlockOk()) : "Concurrent usage error, ensure this never called concurrently";      
    }
}
 
开发者ID:oci-pronghorn,项目名称:FogLight,代码行数:24,代码来源:DefaultCommandChannel.java

示例5: blockUntil

import com.ociweb.iot.maker.Port; //导入依赖的package包/类
@Override
public boolean blockUntil(Port port, long time) {
	assert(enterBlockOk()) : "Concurrent usage error, ensure this never called concurrently";
	try {            

		if (goHasRoom() && PipeWriter.tryWriteFragment(i2cOutput, I2CCommandSchema.MSG_BLOCKCONNECTIONUNTIL_21)) {

			PipeWriter.writeInt(i2cOutput, I2CCommandSchema.MSG_BLOCKCONNECTIONUNTIL_21_FIELD_CONNECTOR_11, port.port);
			PipeWriter.writeInt(i2cOutput, I2CCommandSchema.MSG_BLOCKCONNECTIONUNTIL_21_FIELD_ADDRESS_12, groveAddr);
			PipeWriter.writeLong(i2cOutput, I2CCommandSchema.MSG_BLOCKCONNECTIONUNTIL_21_FIELD_TIMEMS_14, time);

			PipeWriter.publishWrites(i2cOutput);

			MsgCommandChannel.publishGo(1,HardwareImpl.i2cIndex(builder),this);
			return true;
		} else {              
			return false; 
		}

	} finally {
		assert(exitBlockOk()) : "Concurrent usage error, ensure this never called concurrently";      
	}
}
 
开发者ID:oci-pronghorn,项目名称:FogLight,代码行数:24,代码来源:PiCommandChannel.java

示例6: setFourDigitDisplayValue

import com.ociweb.iot.maker.Port; //导入依赖的package包/类
private boolean setFourDigitDisplayValue(Port port, int value){
	switch (value){
		case FourDigitDisplayCommand.INIT:
			return  Grove_FourDigitDisplay.init(this, port);
		
		case FourDigitDisplayCommand.DISPLAY_ON:
			return  Grove_FourDigitDisplay.displayOn(this, port);
		
		case FourDigitDisplayCommand.DISPLAY_OFF:
			return Grove_FourDigitDisplay.displayOff(this, port);
			
		case FourDigitDisplayCommand.SET_BRIGHTNESS + 0:
		case FourDigitDisplayCommand.SET_BRIGHTNESS + 1:
		case FourDigitDisplayCommand.SET_BRIGHTNESS + 2:
		case FourDigitDisplayCommand.SET_BRIGHTNESS + 3:
		case FourDigitDisplayCommand.SET_BRIGHTNESS + 4:
		case FourDigitDisplayCommand.SET_BRIGHTNESS + 5:
		case FourDigitDisplayCommand.SET_BRIGHTNESS + 6:
		case FourDigitDisplayCommand.SET_BRIGHTNESS + 7:
			return Grove_FourDigitDisplay.setBrightness(this, port, value - FourDigitDisplayCommand.SET_BRIGHTNESS);
		
		default:
			return Grove_FourDigitDisplay.printFourDigitsWithColon(this, port, value / 100, value % 100);
		
		}
}
 
开发者ID:oci-pronghorn,项目名称:FogLight,代码行数:27,代码来源:PiCommandChannel.java

示例7: SimpleAnalogTransducer

import com.ociweb.iot.maker.Port; //导入依赖的package包/类
/**
 * Listeners can only be added upon construction.
 * @param ch
 * @param p
 * @param ls var args of listeners specific to this SimpleAnalog device's AnalogEvent.
 */
public SimpleAnalogTransducer(FogCommandChannel ch, Port p, SimpleAnalogListener... ls){
	
	this.p  = p;
	this.ch = ch;

	aListeners = new ArrayList<SimpleAnalogListener>();
	rsListeners = new ArrayList<RunningStdDevListener>();
	msListeners = new ArrayList<MovingStdDevListener>();
	maListeners = new ArrayList<MovingAverageListener>();

	maRollers = new ArrayList<MAvgRollerLong>();

	for (SimpleAnalogListener l: ls){
		aListeners.add(l);
	}
	if (ch != null){
		ch.ensurePinWriting();
	}
}
 
开发者ID:oci-pronghorn,项目名称:FogLight,代码行数:26,代码来源:SimpleAnalogTransducer.java

示例8: analogEvent

import com.ociweb.iot.maker.Port; //导入依赖的package包/类
@Override
public void analogEvent(Port port, long time, long durationMillis, int average, int value) {
	//aListener.analogEvent(port, time, durationMillis, average, value);
	System.out.println("HERE");
	if (port.equals(p)){
		System.out.println("THERE");
		for (SimpleAnalogListener sal: aListeners){
			sal.simpleAnalogEvent(port, time, durationMillis, value);
		}
		for (int i = 0; i < maListeners.size(); i ++){
			MAvgRollerLong.roll(maRollers.get(i), value);
			maListeners.get(i).movingAverage(mean(maRollers.get(i)));
		}
		
	
		
		//TODO: HANDLE THE OTHER 3 STATS LISTENER
	}
}
 
开发者ID:oci-pronghorn,项目名称:FogLight,代码行数:20,代码来源:SimpleAnalogTransducer.java

示例9: analogEvent

import com.ociweb.iot.maker.Port; //导入依赖的package包/类
@Override
public void analogEvent(Port port, long time, long durationMillis, int average, int value) {

	if ((time-lastChange)>200) {
		int pumpStateIndex = value/angleDivisor;
		PumpState state = PumpState.values()[pumpStateIndex];
		logger.info("changed mode to {}",state);
		commandChannel.changeStateTo(state);
		lastChange = time;
	}

}
 
开发者ID:oci-pronghorn,项目名称:FogLight-Examples,代码行数:13,代码来源:ModeSelector.java

示例10: digitalEvent

import com.ociweb.iot.maker.Port; //导入依赖的package包/类
@Override
public void digitalEvent(Port port, long time, long durationMillis, int value) {		
	
	player1Score = 0;
	player2Score = 0;
	resetBallPos();
	gameState = gameState.score;
}
 
开发者ID:oci-pronghorn,项目名称:FogLight-Examples,代码行数:9,代码来源:PongBehavior.java

示例11: analogEvent

import com.ociweb.iot.maker.Port; //导入依赖的package包/类
@Override
public void analogEvent(Port port, long time, long durationMillis, int average, int value) {
	if(port == PongConstants.Player1Con){
		player1Loc = 15-((value-4)/68); //maps 1024 to 0-15
	}else if(port == PongConstants.Player2Con){
		player2Loc = 15-((value-4)/68);
	}
}
 
开发者ID:oci-pronghorn,项目名称:FogLight-Examples,代码行数:9,代码来源:PongBehavior.java

示例12: digitalEvent

import com.ociweb.iot.maker.Port; //导入依赖的package包/类
@Override
public void digitalEvent(Port port, long time, long durationMillis, int value) {
			
	if (1==value) {
		recordedDistance = lastDistance;
		logger.info("record new distance for {} of {}",id,recordedDistance);
	}
			
}
 
开发者ID:oci-pronghorn,项目名称:FogLight-Examples,代码行数:10,代码来源:PhysicalWatcher.java

示例13: commonAnalogEventProcessing

import com.ociweb.iot.maker.Port; //导入依赖的package包/类
protected void commonAnalogEventProcessing(Port port, long time, int value, AnalogListenerBase aListener) {
	
	if (isIncluded(port, includedPorts) && isNotExcluded(port, excludedPorts)) {
		
		int runningValue = sendEveryAnalogValue[port.port] ? value : findStableReading(value, port.port);             
		
		int mean = runningValue;
		//logger.debug(port+" send every value "+sendEveryAnalogValue[port.port]);
		
		if (null!=rollingMovingAveragesAnalog[port.port]) {
			MAvgRollerLong.roll(rollingMovingAveragesAnalog[port.port], runningValue);                                                
			
			if (MAvgRollerLong.isValid(rollingMovingAveragesAnalog[port.port])) {
				mean = (int)MAvgRollerLong.mean(rollingMovingAveragesAnalog[port.port]);
			}
		} else {
			logger.info("warning this port "+port+" is attempting to use moving average but no moving average was set up.\n Was this port connected in declare connections?");
		}
		
		if (sendEveryAnalogValue[port.port]) {
			//set time first so this is 0 the moment it shows up
			//since we send every read we can send the age as greater and geater values as long as it does not change.
			if(runningValue!=lastAnalogValues[port.port]){ 
				lastAnalogTimes[port.port] = time;   
				lastAnalogValues[port.port] = runningValue;
			}
			aListener.analogEvent(port, time, 0==lastAnalogTimes[port.port] ? Long.MAX_VALUE : time-lastAnalogTimes[port.port], mean, runningValue);
			
		} else {								
			if(runningValue!=lastAnalogValues[port.port]){ 
									
				//the duration here is the duration of how long the previous value was held.
				aListener.analogEvent(port, time, 0==lastAnalogTimes[port.port] ? Long.MAX_VALUE : time-lastAnalogTimes[port.port], mean, runningValue);
			   
				lastAnalogValues[port.port] = runningValue;
			    lastAnalogTimes[port.port] = time;
			}
		}
	}
}
 
开发者ID:oci-pronghorn,项目名称:FogLight,代码行数:41,代码来源:ReactiveIoTListenerStage.java

示例14: includePorts

import com.ociweb.iot.maker.Port; //导入依赖的package包/类
@Override
public ListenerFilterIoT includePorts(Port ... ports) {
	if (!startupCompleted && (listener instanceof AnalogListener || listener instanceof DigitalListener)) {
		includedPorts = ports;
		return this;
	} else {
		if (startupCompleted) {
    		throw new UnsupportedOperationException("ListenerFilters may only be set before startup is called.  Eg. the filters can not be changed at runtime.");
    	} else {
    		throw new UnsupportedOperationException("The Listener must be an instance of AnalogLister or DigitalListener in order to call this method.");
    	}
	}
}
 
开发者ID:oci-pronghorn,项目名称:FogLight,代码行数:14,代码来源:ReactiveIoTListenerStage.java

示例15: excludePorts

import com.ociweb.iot.maker.Port; //导入依赖的package包/类
@Override
public ListenerFilterIoT excludePorts(Port ... ports) {
	if (!startupCompleted && (listener instanceof AnalogListener || listener instanceof DigitalListener)) {
		excludedPorts = ports;
		return this;
	} else {
		if (startupCompleted) {
    		throw new UnsupportedOperationException("ListenerFilters may only be set before startup is called.  Eg. the filters can not be changed at runtime.");
    	} else {
    		throw new UnsupportedOperationException("The Listener must be an instance of AnalogLister or DigitalListener in order to call this method.");
    	}
	}
}
 
开发者ID:oci-pronghorn,项目名称:FogLight,代码行数:14,代码来源:ReactiveIoTListenerStage.java


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