Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 """
00010 .. module:: interactions
00011 :platform: Unix
00012 :synopsis: Representative class and methods for an *interaction*.
00013
00014
00015 This module defines a class and methods that represent the core of what
00016 an interaction is for a remocon.
00017
00018 ----
00019
00020 """
00021
00022
00023
00024
00025 import os
00026 import rocon_console.console as console
00027
00028 import rocon_interactions
00029 from . import utils
00030
00031
00032
00033
00034
00035
00036 class Interaction(rocon_interactions.Interaction):
00037 '''
00038 This class defines an interaction for the rocon_remocon.
00039 It does so by wrapping the base
00040 rocon_interaction.Interaction class with a few extra
00041 variables and methods.
00042 '''
00043 __slots__ = [
00044 'launch_list',
00045 'icon',
00046 'index'
00047 ]
00048
00049 def __init__(self, msg):
00050 """
00051 :param msg: underlying data structure with fields minimally filled via :func:`.load_msgs_from_yaml_resource`.
00052 :type msg: rocon_interaction_msgs.Interaction_
00053
00054 .. include:: weblinks.rst
00055 """
00056 super(Interaction, self).__init__(msg)
00057 self.launch_list = {}
00058 self.index = None
00059 icon_name = msg.icon.resource_name.split('/').pop()
00060 if msg.icon.data:
00061 icon = open(os.path.join(utils.get_icon_cache_home(), icon_name), 'w')
00062 icon.write(msg.icon.data)
00063 icon.close()
00064 self.icon = icon_name
00065
00066 def __str__(self):
00067 '''
00068 Format the interaction into a human-readable string.
00069 '''
00070 s = rocon_interactions.Interaction.__str__(self)
00071 s += console.cyan + " Launch List" + console.reset + " : " + console.yellow + "%s" % self.launch_list.keys() + console.reset + '\n'
00072 return s