READERNAME ReaderModuleOnPowerState.java

From RifidiWiki

Revision as of 19:40, 26 November 2010 by Matt (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");
	}


suspend

This method moves the reader into the suspended state. Readers should be able to be 'suspended' and 'resumed' so that functions like 'pause' will work in Rifidi Designer. For the most part, suspend should just queue incoming and outgoing messages. This functionality works by just suspending the communication that the reader is using. The complication comes in when a reader needs to be suspended while in autonomous mode.

public void suspend(PowerControllable pcObject) 

Arguments

  1. pcObject - The ReaderModule

Reference Implementation

This is the implementation of the suspend() method in the Symbol Reader. It works by suspending its communication and controllers. Then it moves the reader into the SuspendedState by calling the changePowerState() method.

Note that because the reader does not have an autonomous mode that is implemented it does not need to do anything else. The LLRP reader does, however, have an autonomous mode, and so it needs to make sure the autonomous mode is suspended. See that reader's OnPowerState class to see how it suspends its autonomous mode.

	public void suspend(PowerControllable pcObject) {
		SymbolReaderModule rm = (SymbolReaderModule) pcObject;
		rm.getHttpComm().suspend();
		rm.getByteComm().suspend();
		rm.getInteractiveBitController().suspend();
		rm.getInteractiveHttpController().suspend();
		
		SymbolReaderSharedResources ssr = rm.getSharedResources();
		
		ssr.getTagMemory().suspend();

		rm.changePowerState(SymbolReaderModuleSuspendedPowerState.getInstance());
		
		String readername = rm.getSharedResources().getReaderName();
		LogFactory.getLog("console." + readername).info(readername + " suspended");

	}
Personal tools