Beispiel #1
0
from StateGraph import *
from XMLParser import *

graph = XMLParser(graph_file="sample1a.xml", debug=False).parse()

# Check currnet state
print("Current State: {}".format(graph.get_current_state().name))

# Simulate an action
print("Simulating Action of VoiceCommand hello")
graph.apply_action(ActionType.VOICE_COMMAND, 'hello')

# Check currnet state
print("Current State: {}".format(graph.get_current_state().name))


"""
Output:

Parsing...
State:
	Name: Root state
	StateActions: 1 actions
		StateAction: (Type: voice_command, Value: hello, To: State that says hello back)
	Responses: 0 responses
State:
	Name: State that says hello back
	StateActions: 0 actions
	Responses: 3 responses
		Response: (Name: Saying Hello Back with LED, Type: led, Value: Some Random LED Value)
		Response: (Name: Sleeping for 5 seconds, Type: sleep, Value: 5000)