READERNAME ReaderModuleOnPowerState.java

From RifidiWiki

Revision as of 22:50, 11 February 2008 by Kyle (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This class needs to be implemented for each reader to handle the state transitions from on->off and from on->suspend. It should extend AbstractOnPowerState.

turnOff

This method should turn the reader and all of its components off.

public void turnOff(PowerControllable pcObject, Class callingClass) 

Arguments

  1. pcObject - The ReaderModule
  2. callingClass - The class that called the turnOff method


Reference Implementation

This is the implementation of the turnOff() method in the Symbol Reader. It basically turns off its two communication objects and controllers. It turns off the controllers by calling their respective turn off methods. It then turns off the communication by turning off each communication object's power and connection signal (Each Communication object has a control signal that represents the whether or not the communication is 'on', and another control signal that represents whether or not the communication is 'connected' to client). Finally, this method moves the symbol reader into the 'off' state by calling the 'changePowerState' method. This method doesn't do anything but declare that the reader is now off.

This method is typical of what needs to happen to turn a reader off; however some reader may need to do other things. For example, if the reader has an autonomous mode, the autonomous mode may need to be turned off.

	public void turnOff(PowerControllable pcObject, Class callingClass) {
		SymbolReaderModule rm = (SymbolReaderModule) pcObject;
		rm.getInteractiveBitController().turnOff(this.getClass());
		rm.getInteractiveHttpController().turnOff(this.getClass());

		rm.getSharedResources().getInteractiveBytePowerSignal()
				.setControlVariableValue(false);
		rm.getSharedResources().getInteractiveHttpPowerSignal()
				.setControlVariableValue(false);
		rm.getSharedResources().getInteractiveByteConnectionSignal()
				.setControlVariableValue(false);
		rm.getSharedResources().getInteractiveHttpConnectionSignal()
				.setControlVariableValue(false);
		
		SymbolReaderSharedResources ssr = rm.getSharedResources();

		rm.changePowerState(SymbolReaderModuleOffPowerState.getInstance());
		
		String readername = rm.getSharedResources().getReaderName();
		LogFactory.getLog("console." + readername).info(readername + " off");
	}


turnOff

This method should turn the reader and all of its components off.

public void turnOff(PowerControllable pcObject, Class callingClass) 

Arguments

  1. pcObject - The ReaderModule
  2. callingClass - The class that called the turnOff method


Reference Implementation

This is the implementation of the turnOff() method in the Symbol Reader. It basically turns off its two communication objects and controllers. It turns off the controllers by calling their respective turn off methods. It then turns off the communication by turning off each communication object's power and connection signal (Each Communication object has a control signal that represents the whether or not the communication is 'on', and another control signal that represents whether or not the communication is 'connected' to client). Finally, this method moves the symbol reader into the 'off' state by calling the 'changePowerState' method. This method doesn't do anything but declare that the reader is now off.

This method is typical of what needs to happen to turn a reader off; however some reader may need to do other things. For example, if the reader has an autonomous mode, the autonomous mode may need to be turned off.

	public void turnOff(PowerControllable pcObject, Class callingClass) {
		SymbolReaderModule rm = (SymbolReaderModule) pcObject;
		rm.getInteractiveBitController().turnOff(this.getClass());
		rm.getInteractiveHttpController().turnOff(this.getClass());

		rm.getSharedResources().getInteractiveBytePowerSignal()
				.setControlVariableValue(false);
		rm.getSharedResources().getInteractiveHttpPowerSignal()
				.setControlVariableValue(false);
		rm.getSharedResources().getInteractiveByteConnectionSignal()
				.setControlVariableValue(false);
		rm.getSharedResources().getInteractiveHttpConnectionSignal()
				.setControlVariableValue(false);
		
		SymbolReaderSharedResources ssr = rm.getSharedResources();

		rm.changePowerState(SymbolReaderModuleOffPowerState.getInstance());
		
		String readername = rm.getSharedResources().getReaderName();
		LogFactory.getLog("console." + readername).info(readername + " off");
	}
Personal tools