예제 #1
0
class AutofabricantesExm:
	
	## Initialization
	def __init__(self):		
		
		logging.basicConfig(level=logging.INFO, format='%(relativeCreated)6d %(threadName)s %(message)s')
				
		## counter
		self.counter  = 0
		
		## default mode
		self.mode = TEST_MODE
		self.setMode()
				
		logging.info("\n---> Setup")

		## inputOutputUtils
		self.inputOutputUtils = InputOutputOutils(self.mode)
		
		## stateMachine
		self.stateMachine = StateMachine(self.inputOutputUtils)
		self.stateMachine.start()
			
		
	## Main execution loop  
	def loop(self):
					
		while(True):
			logging.info("\n---> Loop (%i)", self.counter)
			self.counter = self.counter + 1
			self.stateMachine.executeTransition()
			
	## Reset
	def reset(self): 

		logging.debug("\n---> Reset (%i)", self.counter)		
		self.__init__()
		
 
	## setMode
	def setMode(self):
				
# 		input = GPIO.input(GPIO_INPUT_SWITCH_2)
# 		logging.info("\n---> GPIO_INPUT_SWITCH_0 [%i]", input)
# 		  
# 		if(input == 0):	
# 			## Operation mode					
# 			self.operationMode = OPERATION_MODE
# 		else:
# 			self.operationMode = TEST_MODE
		
		#self.mode = TEST_MODE
		self.mode = OPERATION_MODE
		
		logging.debug("IOUTILS::mode: %d", self.mode)
예제 #2
0
    def test_accept_move_to_self_with_transition(self):
        state_machine = StateMachine()
        state_a = state_machine.define_initial_state('a')
        state_machine.define_transition(state_a, state_a)

        walker = state_machine.start()
        self.assertTrue(walker.move_to(state_a))
        self.assertEqual(state_a, walker.get_state())
예제 #3
0
    def test_starts_in_initial_state(self):
        state_machine = StateMachine()
        state_a = state_machine.define_initial_state('a')
        state_b = state_machine.define_state('b')

        state_machine.define_transition(state_a, state_b)

        walker = state_machine.start()
        self.assertEqual(state_a, walker.get_state())
예제 #4
0
    def test_rejects_move_to_self_without_transition(self):
        state_machine = StateMachine()
        state_a = state_machine.define_initial_state('a')
        state_b = state_machine.define_state('b')

        state_machine.define_transition(state_a, state_b)

        # There is no transition from a to a, so move_to() should return false,
        # however we should still be in state a after.
        walker = state_machine.start()
        self.assertFalse(walker.move_to(state_a))
        self.assertEqual(state_a, walker.get_state())
예제 #5
0
    def test_rejects_move_without_transition(self):
        state_machine = StateMachine()
        state_a = state_machine.define_initial_state('a')
        state_b = state_machine.define_state('b')
        state_c = state_machine.define_state('c')

        state_machine.define_transition(state_a, state_b)
        state_machine.define_transition(state_b, state_c)

        walker = state_machine.start()
        self.assertFalse(walker.move_to(state_c))
        self.assertEqual(state_a, walker.get_state())
예제 #6
0
'''
Created on Aug 5, 2013

@author: nik
'''

from dbmanager import DbManager
import FingerScanner as scanner
from statemachine import StateMachine


if __name__ == '__main__':
    
    dbManager = DbManager()
    statemachine = StateMachine(dbManager)
    statemachine.start()
    
    
    
#     scanner.start(2)