Пример #1
0
    def __init__(self, parent=None, system='OCS', entity='Sequencer', standalone=True):

        # get arguments
        self._parent = parent
        self._system = system
        self._entity = entity
        self._standalone = standalone

        # define some variables and initialize them
        self._command = None
        self._script = None

        # create an instance of this generic entity
        self._sequencer = OcsSequencerEntity(self._system, self._entity, True)

        # now add the GUI stuff
        Frame.__init__(self, self._parent, bd=1, relief=SUNKEN, bg=ocsGenericEntityBackgroundColour.get(
            self._system, OCS_GENERIC_ENTITY_BACKGROUND_COLOUR))
        self._generic = OcsGenericEntityGui(self._parent, self._system, self._entity, self._standalone)
        Label(self._parent, text='{0:s} {1:s}'.format(self._system, self._entity), foreground='blue', bg=ocsGenericEntityBackgroundColour.get(
            self._system, OCS_GENERIC_ENTITY_BACKGROUND_COLOUR),
            font=('helvetica', 12, 'normal')).grid(row=0, sticky=NSEW)
        #Label(self._parent, text='Sequencer', foreground='blue', bg=ocsGenericEntityBackgroundColour.get(
        #    self._system, OCS_GENERIC_ENTITY_BACKGROUND_COLOUR),
        #    font=('helvetica', 12, 'bold')).grid(row=1, sticky=NSEW)
        self.create_sequencer_buttons(self._parent, self._system)

        self._generic._simFlag.trace('w', self.this_change)
# -*- coding: utf-8 -*-


# +
# import(s)
# -
from OcsSequencerEntity import *

# +
# main()
# -
if __name__ == '__main__':

    sequencer = None
    try:
        sequencer = OcsSequencerEntity('OCS', 'Sequencer', False)
    except OcsGenericEntityException as e:
        print(e.errstr)

    if sequencer:

        # disable control
        cmd = 'disable entity=tcs'
        msg = "sequencer.sequence('{0:s}')".format(cmd)
        sequencer.logger.info(msg)
        sequencer.sequence(cmd)

        # standby
        cmd = 'standby entity=tcs'
        msg = "sequencer.sequence('{0:s}')".format(cmd)
        sequencer.logger.info(msg)
            _simulate = True
        else:
            _simulate = False
        _command = seqcli.argd.get('command', '')
        _timeout = seqcli.argd.get('timeout', OCS_GENERIC_COMMAND_TIMEOUT)
    else:
        _system = 'OCS'
        _entity = 'Sequencer'
        _simulate = True
        _command = ''
        _timeout = OCS_GENERIC_COMMAND_TIMEOUT

    # get a generic entity object
    sequencer = None
    try:
        sequencer = OcsSequencerEntity(_system, _entity, _simulate)
    except OcsGenericEntityException as e:
        print(e.errstr)

    # execute the given command
    if sequencer:

        command_lc = _command.lower()
        if command_lc == 'abort':
            try:
                sequencer.abort(_timeout)
            except OcsGenericEntityException as e:
                print(e.errstr)

        elif command_lc == 'disable':
            try:
Пример #4
0
        # start
        entobj.logger.info("{0:s}.start('Normal')".format(entity))
        entobj.start('Normal')

        # enable
        entobj.logger.info('{0:s}.enable()'.format(entity))
        entobj.enable()

    # return
    return

# +
# main()
# -
if __name__ == "__main__":

    # created shared entities
    camera    = OcsCameraEntity('CCS', 'Camera', False)
    sequencer = OcsSequencerEntity('OCS', 'ocs', False)

    # create jobs for each entity:
    jobs = []
    for E in ( camera, sequencer ):
        j = threading.Thread(target=worker_code, args=(E._entity, E))
        jobs.append(j)
        j.start()

    for j in jobs:
        j.join()
        print('{0:s} exited'.format(j.name))
Пример #5
0
class OcsSequencerEntityGui(OcsGenericEntityGui):

    # +
    # __init__ method
    # -
    def __init__(self, parent=None, system='OCS', entity='Sequencer', standalone=True):

        # get arguments
        self._parent = parent
        self._system = system
        self._entity = entity
        self._standalone = standalone

        # define some variables and initialize them
        self._command = None
        self._script = None

        # create an instance of this generic entity
        self._sequencer = OcsSequencerEntity(self._system, self._entity, True)

        # now add the GUI stuff
        Frame.__init__(self, self._parent, bd=1, relief=SUNKEN, bg=ocsGenericEntityBackgroundColour.get(
            self._system, OCS_GENERIC_ENTITY_BACKGROUND_COLOUR))
        self._generic = OcsGenericEntityGui(self._parent, self._system, self._entity, self._standalone)
        Label(self._parent, text='{0:s} {1:s}'.format(self._system, self._entity), foreground='blue', bg=ocsGenericEntityBackgroundColour.get(
            self._system, OCS_GENERIC_ENTITY_BACKGROUND_COLOUR),
            font=('helvetica', 12, 'normal')).grid(row=0, sticky=NSEW)
        #Label(self._parent, text='Sequencer', foreground='blue', bg=ocsGenericEntityBackgroundColour.get(
        #    self._system, OCS_GENERIC_ENTITY_BACKGROUND_COLOUR),
        #    font=('helvetica', 12, 'bold')).grid(row=1, sticky=NSEW)
        self.create_sequencer_buttons(self._parent, self._system)

        self._generic._simFlag.trace('w', self.this_change)

    # +
    # (override trace) method(s)
    # -
    def this_change(self, *args):
        self._sequencer.logger.debug("args = {0:s}".format(str(args)))
        # self._sequencer.logger.debug("self._sequencer._simulate = {0:d}".format(self._sequencer._simulate))
        # self._sequencer.logger.debug("self._generic._this._simulate = {0:d}".format(self._generic._this._simulate))
        simflag = self._generic._simFlag.get()
        self._sequencer._simulate = simflag
        self._generic._this._simulate = simflag
        # self._sequencer.logger.debug("self._generic._this._simulate = {0:d}".format(self._generic._this._simulate))
        # self._sequencer.logger.debug("self._sequencer._simulate = {0:d}".format(self._sequencer._simulate))

    # +
    # methods()
    # -
    def get_sequencer_command_dialog_string(self, name=''):
        s = 'sequencer command dialog box'
        for e1 in self._sequencer.sequencer_help:
            t = e1.split()
            if t[0].lower() == name.lower():
                return e1
        return s

    # +
    # (command) methods()
    # -
    def sequence_handler(self):
        OcsEntryDialog(self, self.get_sequencer_command_dialog_string('sequence_handler'), ['Command'])
        if self._sequencer:
            if self.result:
                self._command = self.result['Command']
                self._sequencer.logger.debug("calling self._sequencer.sequence('{0:s}')".format(
                    str(self._command)))
                self._sequencer.sequence(command=self._command)
            else:
                self._command = ''
                self._sequencer.logger.debug("self._sequencer.sequence('{0:s}') cancelled".format(
                    str(self._command)))

    def script_handler(self):
        OcsEntryDialog(self, self.get_sequencer_command_dialog_string('script_handler'), ['Location'])
        if self._sequencer:
            if self.result:
                self._script = self.result['Location']
                self._sequencer.logger.debug("calling self._sequencer.script_handler('{0:s}')".format(
                    str(self._script)))
                self._sequencer.script(location=self._script)
            else:
                self._script = ''
                self._sequencer.logger.debug("self._sequencer.script_handler('{0:s}') cancelled".format(
                    str(self._script)))

    # +
    # createSequencerButtons() method
    # -
    def create_sequencer_buttons(self, _parent=None, system=''):
        self._parent = _parent
        self._system = system
        for e2 in self._sequencer.sequencer_help:
            t = e2.split()
            tl = t[0].lower()
            if tl == 'sequence':
                widget = Button(self._parent, text=t[0], bg=ocsGenericEntityBackgroundColour.get(
                    self._system, OCS_GENERIC_ENTITY_BACKGROUND_COLOUR),
                    command=self.sequence_handler, font=('helvetica', 12, 'normal'), state=NORMAL)
                widget.grid(row=15, sticky=NSEW)
            elif tl == 'script':
                widget = Button(self._parent, text=t[0], bg=ocsGenericEntityBackgroundColour.get(
                    self._system, OCS_GENERIC_ENTITY_BACKGROUND_COLOUR),
                    command=self.script_handler, font=('helvetica', 12, 'normal'), state=NORMAL)
                widget.grid(row=16, sticky=NSEW)
            else:
                pass
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# +
# import(s)
# -
from OcsSequencerEntity import *

# +
# main()
# -
if __name__ == '__main__':

    sequencer = None
    try:
        sequencer = OcsSequencerEntity('OCS', 'Sequencer', False)
    except OcsGenericEntityException as e:
        print(e.errstr)

    if sequencer:

        # disable
        sequencer.logger.info('sequencer.disable()')
        sequencer.disable()

        # standby
        sequencer.logger.info('sequencer.standby()')
        sequencer.standby()

        # exit control
        sequencer.logger.info('sequencer.exitcontrol()')
Пример #7
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# +
# import(s)
# -
from OcsSequencerEntity import *

# +
# main()
# -
if __name__ == '__main__':

    sequencer = None
    try:
        sequencer = OcsSequencerEntity('OCS', 'Sequencer', False)
    except OcsGenericEntityException as e:
        print(e.errstr)

    if sequencer:

        # enter control
        sequencer.logger.info('sequencer.entercontrol()')
        sequencer.entercontrol()

        # start
        startid = [sys.argv[1] if len(sys.argv) > 1 else 'Sequencer-Normal']
        sequencer.logger.info("sequencer.start('{0:s}')".format(startid[0]))
        sequencer.start(startid[0])

        # enable