Beispiel #1
0
def main():

    # Configures output only to stdout.
    Logger.connectOutputLogger(None)

    GenFactory.getInstance().configureVisitor("TestComponentH",
                                              "ComponentHVisitor", True, True)
    GenFactory.getInstance().configureVisitor("TestComponentCpp",
                                              "ComponentCppVisitor", True,
                                              True)

    initfiles = GenFactory.getInstance().create('initFiles')
    print initfiles
    initfiles('object args')
Beispiel #2
0
def main():
    # Configures output only to stdout.
    Logger.connectOutputLogger(None)

    xmlfile = "../../test/app1a/DuckAppAi.xml"

    print "Topology XML parse test (%s)" % xmlfile
    #
    # Basic usage of this factory to create the component meta-model
    #
    the_parsed_topology_xml = XmlTopologyParser.XmlTopologyParser(xmlfile)
    top = TopoFactory().create(the_parsed_topology_xml)
    #
    # End of usage and comp is the instance of model to be used.
    #
    print "Topology: %s" % top
    print "Namespace: %s" % top.get_namespace()
    print "Comment: %s" % top.get_comment()
    print
    for component in top.get_comp_list():
        print "Component"
        print "    Namespace: " + component.get_namespace()
        print "    Name: " + component.get_name()
        print "    Type: " + component.get_kind()
        if component.get_comment() != None:
            print "    Comment: " + component.get_comment()
        print "    Output Ports:"
        for port in component.get_ports():
            print "        Name: " + port.get_name()
            print "        Port Type: " + port.get_type()
            print "        Direction: " + port.get_direction()
            if port.get_sync() != None:
                print "        Sync: " + port.get_sync()
            if port.get_comment() != None:
                print "        Comment: " + port.get_comment()
            print "        Target Component: " + port.get_target_comp()
            print "        Target Port: " + port.get_target_port()
            print "        Target Type: " + port.get_target_type()
            print "        Target Direction:" + port.get_target_direction()
            print
        print
Beispiel #3
0
def main():

    # Configures output only to stdout.
    Logger.connectOutputLogger(None)

    xmlfile = "../../test/Msg1InterfaceAi.xml"

    print "Port XML parse test (%s)" % xmlfile
    #
    # Basic usage of this factory to create the component meta-model
    #
    the_parsed_port_xml = XmlPortsParser.XmlPortsParser(xmlfile)
    print the_parsed_port_xml.get_args()
    args = the_parsed_port_xml.get_args()  
    for a in args:
        print "\t",a
        print "\t",a.get_name()
        print "\t",a.get_type()
        print "\t",a.get_comment()    
    print the_parsed_port_xml.get_include_header_files()
    print the_parsed_port_xml.get_interface()
    print the_parsed_port_xml.get_interface().get_comment()
    print the_parsed_port_xml.get_interface().get_name()
    print the_parsed_port_xml.get_interface().get_namespace()
    
    port = PortFactory().create(the_parsed_port_xml)
    #
    # End of usage and port is the instance of model to be used.
    #
    print "Port: %s" % port
    print "Namespace: %s" % port.get_namespace()
    print "Type: %s" % port.get_type()
    print "Comment: %s" % port.get_ifcomment()
    print "Includes: %s" % port.get_includes()
    print
    args = port.get_args()
    print "Args: %s" % args
    for a in args:
        print "Arg Name: %s Type: %s Comment: %s" % (a.get_name(), a.get_type(), a.get_comment())
Beispiel #4
0
def main():

    # Configures output only to stdout.
    Logger.connectOutputLogger(None)

    xmlfile = "../../test/app1a/NikonComponentAi.xml"

    print "Component XML parse test (%s)" % xmlfile
    #
    # Basic usage of this factory to create the component meta-model
    #
    parsed_port_xml_list = [] 
    the_parsed_component_xml = XmlComponentParser.XmlComponentParser(xmlfile)    
    port_type_files_list = the_parsed_component_xml.get_port_type_files()
    for port_file in port_type_files_list:
        #print "Parsing %s" % port_file
        parsed_port_xml_list.append(XmlPortsParser.XmlPortsParser(port_file))
        #print parsed_port_xml_list
    comp = CompFactory().create(the_parsed_component_xml, parsed_port_xml_list)
    #
    # End of usage and comp is the instance of model to be used.
    #
    print "Component: %s" % comp
    print "Namespace: %s" % comp.get_namespace()
    print "Name: %s" % comp.get_name()
    print "Kind: %s" % comp.get_kind()
    print "Comment: %s" % comp.get_comment()
    print "Ports: %s" % comp.get_ports()
    print
    for port in comp.get_ports():
        print "Port:"
        print port.get_name(), port.get_type(), port.get_direction(), port.get_sync(), port.get_namespace()
        print port.get_comment()
        print port.get_ifcomment()
        print port.get_includes()
        print port.get_args()
        for arg in port.get_args():
            print "\t%s : %s  # %s" % (arg.get_name(), arg.get_type(), arg.get_comment())
Beispiel #5
0
def set_logger(log_folder=None, log_name="downlink.log"):
    """
    Set the module level logger.
    @param log_folder: downlink log folder
    @param log_name: downlink log name (default="downlink.log")
    """
    global LOGGER

    if log_folder is None or log_folder == 'None':
        f = None
    else:
        f = os.path.join(log_folder, log_name)

    LOGGER = Logger.connectOutputLogger(file=f, logger_name=LOGGER_NAME, logger_level=logging.INFO)
Beispiel #6
0
    def setupLogging(self, opt=None):
        """
        Set up logging once for the singleton to use.
        """

        if opt == None:
            p = os.environ['HOME'] + os.sep + 'fprime_logs' + os.sep + "status"
        else:
            p = opt.log_file_path + os.sep + opt.log_file_prefix + os.sep + "status"
        #
        self.__opt = opt
        logfile = 'Status.log'
        #
        if not os.path.exists(p):
            os.makedirs(p)
        f = p + os.sep + logfile
        self.__logger = Logger.connectOutputLogger(f)
        self.__logger.info("Created log: %s" % f)
        self.__logger.info("User: %s" % os.environ['USER'])
Beispiel #7
0
    def __init__(self,
                 server_addr='127.0.0.1',
                 port=50000,
                 generated_path='',
                 build_root='',
                 log_file_cmds=None,
                 log_file_events=None,
                 log_file_channel=None,
                 log_file_path=None,
                 log_file_updown=None,
                 listener_enabled=False,
                 verbose=False):
        """
        Constructor.
        @param server_addr: Socket server addr
        @param port: Socket server port number
        @param log_file_cmds: Name of command log file
        @param log_file_events: Name of log event log file
        @param log_file_channel: Name of channel telemetry log file
        @param log_file_path: Name of common directory path to save log files into
        @param listener_enabled: If True then event/channel telemetry listener thread enabled, else dissabled
        @param verbose: Enable diagonistic display of information
        """
        # 1. Connect to socket server using controllers.client_sock.py
        # 2. Create log files and loggers
        # 3. Load configuration for commands, events, channels, using controllers.XXXXX_loader.py
        # 3. Start listener thread controllers.event_listern.py

        # For every console output log to a default file and stdout.
        logfile = time.strftime("%y%m%d%H%M%S",
                                time.gmtime()) + '_GSEStdOut.log'
        #p = opts.log_file_path + os.sep + "stdout"
        p = '.' + os.sep + "stdout"
        if not os.path.exists(p):
            os.makedirs(p)
        f = p + os.sep + logfile

        # setup default for generated python command / telemetry descriptor files.
        # these are autocoded descriptions of all.
        #
        # Look for BUILD_ROOT and if not set look for generated in "." and then
        # in ".." and if not found then throw an exception.

        config = ConfigManager.getInstance()

        self.build_root = config.get("filepaths", "build_root")
        if 'BUILD_ROOT' in os.environ:
            self.build_root = os.environ['BUILD_ROOT']
        elif build_root != '':
            self.build_root = build_root
        else:
            print "WARNING: BUILD_ROOT not set. Specify on the command line, the environment, or gse.ini."

        self.generated_path = config.get("filepaths", "generated_path")
        if generated_path != '':
            self.generated_path = generated_path
        else:
            print "WARNING: GENERATED_PATH not set. Specify on command line or gse.ini"

        # display configuration before starting GUI here...
        sep_line = 80 * "="
        if verbose:
            logger = Logger.connectOutputLogger(f, 'stdout', logging.INFO)
        else:
            logger = Logger.connectOutputLogger(f, 'stdout', logging.WARNING)
        logger.info("Created log: %s" % f)
        logger.info("User: %s" % os.environ['USER'])
        (sysname, nodename, release, version, machine) = os.uname()
        logger.info("OS Name: %s" % sysname)
        logger.info("Machine Network Host Name: %s" % nodename)
        logger.info("Release: %s" % release)
        logger.info("Version: %s" % version)
        logger.info("Machine: %s" % machine)
        logger.info(sep_line)

        # load commands, events, channelized telemetry, and event listener
        sys.path.append(generated_path)
        # add path for serializables
        sys.path.append(generated_path + os.sep + "serializable")

        self._cmds = command_loader.CommandLoader.getInstance()
        self._cmds.create(generated_path + os.sep + "commands")
        self._events = event_loader.EventLoader.getInstance()
        self._events.create(generated_path + os.sep + "events")
        self._channels = channel_loader.ChannelLoader.getInstance()
        self._channels.create(generated_path + os.sep + "channels")
        self.__args_factory = command_args_factory.CommandArgsFactory()
        self._ev_listener = event_listener.EventListener.getInstance()
        self._ev_listener.setupLogging()
        self.__logger = logger

        self.__server_addr = server_addr
        self.__port = port

        # Uplink and downlink clients will log to null handler if none is specified
        file_uplink_client.set_logger(log_folder=log_file_updown)
        file_downlink_client.set_logger(log_folder=log_file_updown)

        # connect to TCP server
        try:
            self.__sock = client_sock.ClientSocket(server_addr, port)
            self.__sock.send("Register GUI\n")
            self._ev_listener.connect(self.__sock)
        except IOError:
            self.__sock = None

        super(GseApi, self).__init__()
Beispiel #8
0
def main(argv=None):
    '''
    Command line options.
    '''
    global LOGGER
    #
    program_name = os.path.basename(sys.argv[0])
    program_version = "v0.1"
    program_build_date = "%s" % __updated__

    program_version_string = '%%prog %s (%s)' % (program_version,
                                                 program_build_date)
    #program_usage = '''usage: spam two eggs''' # optional - will be autogenerated by optparse
    program_longdesc = ''''''  # optional - give further explanation about what the program does
    program_license = "Copyright 2015 user_name (California Institute of Technology)                                            \
                ALL RIGHTS RESERVED. U.S. Government Sponsorship acknowledged."

    if argv is None:
        argv = sys.argv[1:]
    try:

        # Get ConfigManager
        config_manager = ConfigManager.ConfigManager.getInstance()
        # Set default values
        generated_path = config_manager.get("filepaths", "generated_path")
        log_file_path = config_manager.get("filepaths", "log_file_path")

        fsw_app = None

        #
        # setup option parser
        parser = OptionParser(version=program_version_string,
                              epilog=program_longdesc,
                              description=program_license)
        parser.add_option("-d", "--dictionary", dest="generated_path", action="store", type="string", \
                          help="Set base path to generated command/telemetry definition files [default: %default]", \
                          default=generated_path)
        parser.add_option("-a", "--addr", dest="addr", action="store", type="string", help="set threaded tcp socket server address [default: %default]", \
                          default="127.0.0.1")
        parser.add_option("-c", "--connect", action="store_true", dest="connect", help="Launches the Threaded TCP Socket Server on startup and connect to it [default: %default]", \
                          default=False)
        parser.add_option("-p", "--port", dest="port", action="store", type="int", help="Set threaded tcp socket server port [default: %default]", \
                          #default=50007)
                          #default=PortFinder.old_getport(50000,[]))


                          )
        parser.add_option("-e", "--execute", dest="exec_app", action="store", type="string", help="Execute the specified fsw application after socket server and UI are up [default: %default]", \
                          default=fsw_app)
        parser.add_option("-L", "--log-file-path", dest="log_file_path", action="store", type="string", help="Path to log files [default: %default]", \
                          default=log_file_path)
        parser.add_option("-b", "--logbinary", dest="bin_logger_flag", action="store", type="int", help="Flag to log raw data from socket (1=ON, 0=OFF) [default: %default]", \
                          default=Logger.BIN_LOGGER_FLAG)
        parser.add_option("-r", "--log-file-prefix", dest="log_file_prefix", action="store", type="string", help="Prefix in log file path for each run. [default: current date/time]", \
                          default=None)
        parser.add_option("-l", "--log-time", dest="log_time", action="store", type="string", help="Time used for logging. (local, GMT)", \
                          default="local")
        parser.add_option("-n", "--no-about", dest="no_about", action="store_true", help="Do not show about text screen on start", \
                          default=True)

        #parser.add_option("-v", "--verbose", dest="verbose", action="count", help="set verbosity level [default: %default]")

        # process options
        (opts, args) = parser.parse_args(argv)
        #
        # Launch the Threaded TCP Server here...

        # check for gm time in options
        if not (opts.log_time == "GMT" or opts.log_time == "local"):
            raise Exception("-l,--log-time must be \"local\" or \"GMT\"")
        if opts.log_time == "GMT" and opts.log_file_prefix == None:
            opts.log_file_prefix = time.strftime("%Y-%m-%d_%H-%M-%S",
                                                 time.gmtime())
        elif opts.log_time == "local" and opts.log_file_prefix == None:
            opts.log_file_prefix = time.strftime("%Y-%m-%d_%H-%M-%S",
                                                 time.localtime())

        # Make sure dictionary directory exists
        print "Generated path %s" % opts.generated_path
        if not os.path.exists(opts.generated_path):
            sys.stderr.write("Error: dictionary directory %s does not exist." %
                             opts.generated_path)
            sys.exit(-1)

        #
        if opts.connect == True or opts.exec_app != None:
            connect(opts)
            opts.connect = True

        # set the binary logger flag
        Logger.setBinLoggerFlag(opts.bin_logger_flag)

        # make the

        #
        # For every console output log to a default file and stdout.
        #
        logfile = 'StdOut.log'
        p = opts.log_file_path + os.sep + opts.log_file_prefix + os.sep + "stdout"
        if not os.path.exists(p):
            os.makedirs(p)
        f = p + os.sep + "stdout.log"
        #
        # display configuration before starting GUI here...
        #
        sep_line = 80 * "="
        logger = Logger.connectOutputLogger(f, 'stdout')
        logger.info("Created log: %s" % f)
        logger.info("User: %s" % os.environ['USER'])
        (sysname, nodename, release, version, machine) = os.uname()
        logger.info("OS Name: %s" % sysname)
        logger.info("Machine Network Host Name: %s" % nodename)
        logger.info("Release: %s" % release)
        logger.info("Version: %s" % version)
        logger.info("Machine: %s" % machine)
        #
        logger.info(sep_line)
        logger.info("Generated command/telemetry definition files: %s" %
                    opts.generated_path)
        logger.info("Threaded TCP Socket Server Address: %s" % opts.addr)
        logger.info("Connection and starting Threaded TCP Socket Server: %s" %
                    opts.connect)
        logger.info("Threaded TCP Socket Server Port: %s" % opts.port)
        logger.info("Execution of FSW Binary Application: %s" % opts.exec_app)
        logger.info("Path to log files: %s" % opts.log_file_path)
        logger.info(sep_line)
        LOGGER = logger
        #
        # MAIN BODY #
        root = main_window_start(opts)
        root.geometry("900x800+10+10")
        #
        # Launch an FSW applicaiton but only after the gse.py is ready.
        #
        if opts.exec_app != None:
            root.after(1000, execute, opts)
        root.mainloop()

    except controllers.exceptions.GseControllerException, e:
        sys.stderr.write("Exception: %s\n" % e.getMsg())
        traceback.print_exc()
        return 2