import matplotlib.pyplot as plt

from cozmo_fsm import *

class Lab8(StateMachineProgram):
    def user_image(self,image,gray):
        self.robot.myimage = gray

    class ShowImage(StateNode):
        def start(self,event):
            super().start(event)
            plt.imshow(robot.myimage, cmap=plt.gray())
            plt.show(block=False)

    def setup(self):
        """
            # Slight delay allows time for first camera image to arrive.
            StateNode() =T(0.5)=> self.ShowImage()
        """
        
        # Code generated by genfsm on Sun Mar 24 12:10:25 2019:
        
        statenode1 = StateNode() .set_name("statenode1") .set_parent(self)
        showimage1 = self.ShowImage() .set_name("showimage1") .set_parent(self)
        
        timertrans1 = TimerTrans(0.5) .set_name("timertrans1")
        timertrans1 .add_sources(statenode1) .add_destinations(showimage1)
        
        return self
