Example #1
0
def main():
    opt, args = get_options()
    cmd_set_args = [Ska.ParseCM._coerce_type(x) for x in args]

    # Configure logging to emit msgs to stdout
    logging.basicConfig(level=opt.loglevel,
                        format='%(message)s',
                        stream=sys.stdout)

    logging.info('Connecting to db: dbi=%s server=%s' % (opt.dbi, opt.server))
    db = Ska.DBI.DBI(dbi=opt.dbi, server=opt.server,
                     user=opt.user, database=opt.database, verbose=False)

    # Print information about recent non-load commands
    nl_cmds = db.fetchall("SELECT * FROM cmds "
                          "WHERE timeline_id IS NULL ORDER BY date DESC")
    # Convert from np.recarray to list of dict (with params included)
    nl_cmds = _tl_to_bs_cmds(nl_cmds, None, db)
    logging.info('Most recent non-load commands')
    log_cmds(nl_cmds[:10])
    logging.info('')

    # Jump out if only doing a check
    if opt.check:
        sys.exit(0)

    # Generate commands for the specified command set
    date = DateTime(opt.date).date
    cmd_set_states = cmd_states.cmd_set(opt.cmd_set, *cmd_set_args)
    cmds = cmd_states.generate_cmds(date, cmd_set_states)

    logging.info('Add following cmds to database')
    log_cmds(cmds)
    logging.info('')

    # Add commands to database if not doing a dry run
    if not opt.dry_run:
        logging.info('Adding cmds to database')
        cmd_states.insert_cmds_db(cmds, None, db)

    # Generate python that will add the same commands to the database
    f = (sys.stdout if opt.dry_run else open(opt.archive_file, 'a'))
    logging.info('Appending cmd_set info to %s' % opt.archive_file)
    # String representation of cmd_set and args
    str_args = [repr(arg) for arg in [opt.cmd_set] + cmd_set_args]
    print('', file=f)
    print('# Autogenerated by add_nonload_cmds.py at %s' % time.ctime(), file=f)
    print('# date=%s cmd_set=%s args=%s' % (date, opt.cmd_set, ' '.join(args)), file=f)
    print("cmds = generate_cmds('%s', cmd_set(%s))" % (date, ', '.join(str_args)), file=f)
    print("cmd_states.insert_cmds_db(cmds, None, db)", file=f)

    if opt.interrupt:
        if not opt.dry_run:
            cmd_states.interrupt_loads(date, db,
                                       observing_only=opt.observing_only)
        print(("cmd_states.interrupt_loads('%s', db, "
                    "observing_only=%s, current_only=True)" %
                    (date, opt.observing_only)), file=f)
Example #2
0
    opt, args = parser.parse_args()
    return opt, args

opt, args = get_options()

db = Ska.DBI.DBI(dbi=opt.dbi, server=opt.server,
                 user=opt.user, database=opt.database)

# Drop all existing non-load commands
for table in ('cmd_intpars', 'cmd_fltpars', 'cmds'):
    db.execute('DELETE FROM %s WHERE timeline_id is NULL' % table)

cmds = []

# Normal sun mode day 2008:225
cmds += generate_cmds('2008:225:10:00:00', cmd_set('nsm')) 
cmds += generate_cmds('2008:227:20:00:00', cmd_set('manvr', 0.734142,-0.111682,0.558589,0.369515 ))
cmds += generate_cmds('2008:227:21:25:00', cmd_set('manvr', 0.784368,-0.0804672,0.535211,0.303053))
cmds += generate_cmds('2008:227:22:15:00', cmd_set('manvr', 0.946291,-0.219412,0.0853751,0.221591))

# Normal sun mode '2008:292:23:24:56'
cmds += generate_cmds('2008:292:21:24:00', cmd_set('nsm'))
cmds += generate_cmds('2008:292:21:24:00', cmd_set('obsid', 0))
cmds += generate_cmds('2008:294:22:20:00', cmd_set('manvr', 0.608789,0.335168,0.717148,0.0523189))
cmds += generate_cmds('2008:295:02:35:00', cmd_set('manvr', 0.542935,0.333876,0.766926,0.0746532))
cmds += generate_cmds('2008:295:03:25:00', cmd_set('manvr', 0.866838,0.243633,0.362662,0.240231))

# NSM in 2004
cmds += generate_cmds('2004:315:16:41:00', cmd_set('nsm'))

    opt, args = parser.parse_args()
    return opt, args

opt, args = get_options()

db = Ska.DBI.DBI(dbi=opt.dbi, server=opt.server,
                 user=opt.user, database=opt.database)

# Drop all existing non-load commands
for table in ('cmd_intpars', 'cmd_fltpars', 'cmds'):
    db.execute('DELETE FROM %s WHERE timeline_id is NULL' % table)

cmds = []

# Normal sun mode day 2008:225
cmds += generate_cmds('2008:225:10:00:00', cmd_set('nsm')) 
cmds += generate_cmds('2008:227:20:00:00', cmd_set('manvr', 0.734142,-0.111682,0.558589,0.369515 ))
cmds += generate_cmds('2008:227:21:25:00', cmd_set('manvr', 0.784368,-0.0804672,0.535211,0.303053))
cmds += generate_cmds('2008:227:22:15:00', cmd_set('manvr', 0.946291,-0.219412,0.0853751,0.221591))

# Normal sun mode '2008:292:23:24:56'
cmds += generate_cmds('2008:292:21:24:00', cmd_set('nsm'))
cmds += generate_cmds('2008:292:21:24:00', cmd_set('obsid', 0))
cmds += generate_cmds('2008:294:22:20:00', cmd_set('manvr', 0.608789,0.335168,0.717148,0.0523189))
cmds += generate_cmds('2008:295:02:35:00', cmd_set('manvr', 0.542935,0.333876,0.766926,0.0746532))
cmds += generate_cmds('2008:295:03:25:00', cmd_set('manvr', 0.866838,0.243633,0.362662,0.240231))

# NSM in 2004
cmds += generate_cmds('2004:315:16:41:00', cmd_set('nsm'))

Example #4
0
    opt, args = parser.parse_args()
    return opt, args

opt, args = get_options()

db = Ska.DBI.DBI(dbi=opt.dbi, server=opt.server,
                 user=opt.user, database=opt.database)

# Drop all existing non-load commands
for table in ('cmd_intpars', 'cmd_fltpars', 'cmds'):
    db.execute('DELETE FROM %s WHERE timeline_id is NULL' % table)

cmds = []

# Normal sun mode day 2008:225
cmds += generate_cmds('2008:225:10:00:00', cmd_set('nsm')) 
cmds += generate_cmds('2008:227:20:00:00', cmd_set('manvr', 0.734142,-0.111682,0.558589,0.369515 ))
cmds += generate_cmds('2008:227:21:25:00', cmd_set('manvr', 0.784368,-0.0804672,0.535211,0.303053))
cmds += generate_cmds('2008:227:22:15:00', cmd_set('manvr', 0.946291,-0.219412,0.0853751,0.221591))

# Normal sun mode '2008:292:23:24:56'
cmds += generate_cmds('2008:292:21:24:00', cmd_set('nsm'))
cmds += generate_cmds('2008:292:21:24:00', cmd_set('obsid', 0))
cmds += generate_cmds('2008:294:22:20:00', cmd_set('manvr', 0.608789,0.335168,0.717148,0.0523189))
cmds += generate_cmds('2008:295:02:35:00', cmd_set('manvr', 0.542935,0.333876,0.766926,0.0746532))
cmds += generate_cmds('2008:295:03:25:00', cmd_set('manvr', 0.866838,0.243633,0.362662,0.240231))

# NSM in 2004
cmds += generate_cmds('2004:315:16:41:00', cmd_set('nsm'))