Esempio n. 1
0
    def main(self):
        """ Execute this method once.
        """

        # get hardware injection in the future that is soonest
        self.hwinj = injtools.check_imminent_injection(hwinj_list, imminent_seconds)
        notify("INJECTION IMMINENT: %f"%self.hwinj.schedule_time)
        if not self.hwinj: return "FAILURE_INJECT_IN_PAST"

        # get a sorted list of hardware injections by their start time
        sorted_hwinj_list = sorted(hwinj_list, key=lambda hwinj: hwinj.schedule_time)

        # if this is the first injection that will be performed then do check
        # otherwise continue because check would have already been done
        if self.hwinj.schedule_time == sorted_hwinj_list[0].schedule_time \
                and len(sorted_hwinj_list) > 1:

            # check that no two injections are too close together
            # this is a safeguard to do before an injection in case someone
            # did not validate the schedule
            for hwinj_1, hwinj_2 in zip(sorted_hwinj_list, sorted_hwinj_list[1:]):
                dt = hwinj_2.schedule_time - hwinj_1.schedule_time
                if dt > 0 and abs(dt) < imminent_seconds:
                    message = "Schedule has two injections %f seconds"%dt \
                        + " apart but must be at least %f"%imminent_seconds \
                        + " seconds apart"
                    log(message)
                    log("Injections are %s and %s"%(str(hwinj_1), str(hwinj_2)))
                    return "FAILURE_SCHEDULED_TWO_INJECT_TOO_CLOSE"

        # print statement
        else:
            log("Skipping checking schedule times since its already been done.")

        return True
Esempio n. 2
0
    def main(self):
        """ Execute method once.
        """

        # get hardware injection in the future that is soonest
        self.hwinj = injtools.check_imminent_injection(hwinj_list,
                                                       imminent_seconds)
        notify("INJECTION IMMINENT: %f" % self.hwinj.schedule_time)
        if not self.hwinj: return "FAILURE_INJECT_IN_PAST"

        # create and open an ArbitraryStream for HardwareInjection
        # this is the object from the awg module that will control
        # the injection
        try:
            self.hwinj.create_stream(ezca.ifo + ":" + exc_channel_name,
                                     sample_rate)
        except:
            etype, val, tb = sys.exc_info()
            ftb = traceback.format_tb(tb)
            for line in ftb:
                log(line)
            log(str(etype) + " " + str(val))
            return "FAILURE_TO_CREATE_STREAM"

        return True
Esempio n. 3
0
    def main(self):
        """ Execute method once.
        """

        # get hardware injection in the future that is soonest
        self.hwinj = injtools.check_imminent_injection(hwinj_list, imminent_seconds)
        notify("INJECTION ACTIVE: %f"%self.hwinj.schedule_time)
        if not self.hwinj: return "FAILURE_INJECT_IN_PAST"

        # close stream and perform injection
        # waits for injection to finish
        try:
            self.hwinj.stream.send(self.hwinj.data)
        except:
            etype, val, tb = sys.exc_info()
            ftb = traceback.format_tb(tb)
            for line in ftb: log(line)
            log(str(etype) + " " + str(val))
            return "FAILURE_DURING_ACTIVE_INJECT"

        # check if stream is open when it should be closed
        if self.hwinj.stream.opened:
            self.hwinj.stream.abort()
            return "FAILURE_AWG_STREAM_NOT_CLOSED"

        # explicitly record the data from the schedule file
        log("GPS start time: %f"%self.hwinj.schedule_time)
        log("Requested state: %s"%self.hwinj.schedule_state)
        log("Requested observation mode: %d"%self.hwinj.observation_mode)
        log("Scale factor: %f"%self.hwinj.scale_factor)
        log("Waveform path: %s"%self.hwinj.waveform_path)
        log("Meta-data path: %s"%self.hwinj.metadata_path)

        return True
Esempio n. 4
0
    def main(self):
        """ Execute method once.
        """
 
        # get hardware injection in the future that is soonest
        self.hwinj = injtools.check_imminent_injection(hwinj_list, imminent_seconds)
        notify("INJECTION IMMINENT: %f"%self.hwinj.schedule_time)
        if not self.hwinj: return "FAILURE_INJECT_IN_PAST"

        return False
Esempio n. 5
0
    def main(self):
        """ Execute method once.
        """

        # get hardware injection in the future that is soonest
        self.hwinj = injtools.check_imminent_injection(hwinj_list,
                                                       imminent_seconds)
        notify("INJECTION IMMINENT: %f" % self.hwinj.schedule_time)
        if not self.hwinj: return "FAILURE_INJECT_IN_PAST"

        return False
Esempio n. 6
0
    def run(self):
        """ Execute method in a loop.
        """

        # get hardware injection in the future that is soonest
        self.hwinj = injtools.check_imminent_injection(hwinj_list,
                                                       imminent_seconds)

        # if there is no imminent hardware injection then recheck injections
        if not self.hwinj:
            return False

        # in dev mode ignore if detector is locked
        # otherwise check if detector is locked
        if ezca[lock_channel_name] == 1 or dev_mode:

            # check if detector in desired observing mode and
            # then make a jump transition to CREATE_GRACEDB_EVENT state
            latch = ezca[obs_channel_name] & obs_bitmask
            if ( latch == 1 and self.hwinj.observation_mode == 1 ) or \
                    ( latch == 0 and self.hwinj.observation_mode == 0 ):

                # legacy of the old setup to set TINJ_START_TIME
                current_gps_time = gpstime.utcnow().gps()
                ezca[start_channel_name] = current_gps_time

                # set legacy TINJ_OUTCOME value for pending injection
                ezca[outcome_channel_name] = 0

                return True

            # set legacy TINJ_OUTCOME value for detector not in desired
            # observation mode
            else:
                log("Ignoring hardware injection since detector is not in " \
                    + "the desired observation mode.")
                ezca[outcome_channel_name] = -5

        # set legacy TINJ_OUTCOME value for detector not locked
        else:
            log("Ignoring hardware injection since detector is not locked.")
            ezca[outcome_channel_name] = -6

        return False
Esempio n. 7
0
    def main(self):
        """ Execute method once.
        """

        # get hardware injection in the future that is soonest
        self.hwinj = injtools.check_imminent_injection(hwinj_list,
                                                       imminent_seconds)
        notify("INJECTION IMMINENT: %f" % self.hwinj.schedule_time)
        if not self.hwinj: return "FAILURE_INJECT_IN_PAST"

        # legacy of the old setup to set TINJ_TYPE
        tinj_type_dict = {
            "INJECT_CBC_ACTIVE": 1,
            "INJECT_BURST_ACTIVE": 2,
            "INJECT_DETCHAR_ACTIVE": 3,
            "INJECT_STOCHASTIC_ACTIVE": 4,
        }
        ezca[type_channel_name] = tinj_type_dict[self.hwinj.schedule_state]

        # try to upload an event to GraceDB
        try:

            # map injection state to GraceDB group
            group = gracedb_group_dict[self.hwinj.schedule_state]

            # log meta-data file path
            log("Reading meta-data from %s" % self.hwinj.metadata_path)

            # upload hardware injection to GraceDB
            self.hwinj.gracedb_id = injtools.gracedb_upload_injection(
                self.hwinj, [ezca.ifo], group=group)
            log("GraceDB ID is " + self.hwinj.gracedb_id)

        # if an unexpected error was encountered then jump to failure state
        except:
            etype, val, tb = sys.exc_info()
            ftb = traceback.format_tb(tb)
            for line in ftb:
                log(line)
            log(str(etype) + " " + str(val))
            return "FAILURE_CREATE_GRACEDB_EVENT"

        return True
Esempio n. 8
0
    def run(self):
        """ Execute method in a loop.
        """

        # get hardware injection in the future that is soonest
        self.hwinj = injtools.check_imminent_injection(hwinj_list, imminent_seconds)

        # if there is no imminent hardware injection then recheck injections
        if not self.hwinj:
            return False

        # in dev mode ignore if detector is locked
        # otherwise check if detector is locked
        if ezca[lock_channel_name] == 1 or dev_mode:

            # check if detector in desired observing mode and
            # then make a jump transition to CREATE_GRACEDB_EVENT state
            latch = ezca[obs_channel_name] & obs_bitmask
            if ( latch == 1 and self.hwinj.observation_mode == 1 ) or \
                    ( latch == 0 and self.hwinj.observation_mode == 0 ):

                # legacy of the old setup to set TINJ_START_TIME
                current_gps_time = gpstime.utcnow().gps()
                ezca[start_channel_name] = current_gps_time

                # set legacy TINJ_OUTCOME value for pending injection
                ezca[outcome_channel_name] = 0

                return True

            # set legacy TINJ_OUTCOME value for detector not in desired
            # observation mode
            else:
                log("Ignoring hardware injection since detector is not in " \
                    + "the desired observation mode.")
                ezca[outcome_channel_name] = -5

        # set legacy TINJ_OUTCOME value for detector not locked
        else:
            log("Ignoring hardware injection since detector is not locked.")
            ezca[outcome_channel_name] = -6

        return False
Esempio n. 9
0
    def main(self):
        """ Execute method once.
        """

        # get hardware injection in the future that is soonest
        self.hwinj = injtools.check_imminent_injection(hwinj_list, imminent_seconds)
        notify("INJECTION IMMINENT: %f"%self.hwinj.schedule_time)
        if not self.hwinj: return "FAILURE_INJECT_IN_PAST"

        # legacy of the old setup to set TINJ_TYPE
        tinj_type_dict = {
            "INJECT_CBC_ACTIVE" : 1,
            "INJECT_BURST_ACTIVE" : 2,
            "INJECT_DETCHAR_ACTIVE" : 3,
            "INJECT_STOCHASTIC_ACTIVE" : 4,
        }
        ezca[type_channel_name] = tinj_type_dict[self.hwinj.schedule_state]

        # try to upload an event to GraceDB
        try:

            # map injection state to GraceDB group
            group = gracedb_group_dict[self.hwinj.schedule_state]

            # log meta-data file path
            log("Reading meta-data from %s"%self.hwinj.metadata_path)

            # upload hardware injection to GraceDB
            self.hwinj.gracedb_id = injtools.gracedb_upload_injection(self.hwinj,
                                           [ezca.ifo], group=group)
            log("GraceDB ID is " + self.hwinj.gracedb_id)

        # if an unexpected error was encountered then jump to failure state
        except:
            etype, val, tb = sys.exc_info()
            ftb = traceback.format_tb(tb)
            for line in ftb: log(line)
            log(str(etype) + " " + str(val))
            return "FAILURE_CREATE_GRACEDB_EVENT"

        return True
Esempio n. 10
0
    def main(self):
        """ Execute method once.
        """

        # get hardware injection in the future that is soonest
        self.hwinj = injtools.check_imminent_injection(hwinj_list,
                                                       imminent_seconds)
        notify("INJECTION IMMINENT: %f" % self.hwinj.schedule_time)
        if not self.hwinj: return "FAILURE_INJECT_IN_PAST"

        # legacy of the old setup to set TINJ_TYPE
        tinj_type_dict = {
            "INJECT_CBC_ACTIVE": 1,
            "INJECT_BURST_ACTIVE": 2,
            "INJECT_DETCHAR_ACTIVE": 3,
            "INJECT_STOCHASTIC_ACTIVE": 4,
        }
        ezca[type_channel_name] = tinj_type_dict[self.hwinj.schedule_state]

        # create a dict for formatting strings
        format_dict = {
            "ifo": ezca.ifo,
        }

        # try to read waveform file
        try:
            log("Reading waveform data from %s" %
                self.hwinj.waveform_path.format(**format_dict))
            self.hwinj.data = self.hwinj.read_data(format_dict=format_dict)

        # if an unexpected error was encountered then jump to failure state
        except:
            etype, val, tb = sys.exc_info()
            ftb = traceback.format_tb(tb)
            for line in ftb:
                log(line)
            log(str(etype) + " " + str(val))
            return "FAILURE_READ_WAVEFORM"

        return True
Esempio n. 11
0
    def main(self):
        """ Execute this method once.
        """

        # get hardware injection in the future that is soonest
        self.hwinj = injtools.check_imminent_injection(hwinj_list,
                                                       imminent_seconds)
        notify("INJECTION IMMINENT: %f" % self.hwinj.schedule_time)
        if not self.hwinj: return "FAILURE_INJECT_IN_PAST"

        # get a sorted list of hardware injections by their start time
        sorted_hwinj_list = sorted(hwinj_list,
                                   key=lambda hwinj: hwinj.schedule_time)

        # if this is the first injection that will be performed then do check
        # otherwise continue because check would have already been done
        if self.hwinj.schedule_time == sorted_hwinj_list[0].schedule_time \
                and len(sorted_hwinj_list) > 1:

            # check that no two injections are too close together
            # this is a safeguard to do before an injection in case someone
            # did not validate the schedule
            for hwinj_1, hwinj_2 in zip(sorted_hwinj_list,
                                        sorted_hwinj_list[1:]):
                dt = hwinj_2.schedule_time - hwinj_1.schedule_time
                if dt > 0 and abs(dt) < imminent_seconds:
                    message = "Schedule has two injections %f seconds"%dt \
                        + " apart but must be at least %f"%imminent_seconds \
                        + " seconds apart"
                    log(message)
                    log("Injections are %s and %s" %
                        (str(hwinj_1), str(hwinj_2)))
                    return "FAILURE_SCHEDULED_TWO_INJECT_TOO_CLOSE"

        # print statement
        else:
            log("Skipping checking schedule times since its already been done."
                )

        return True
Esempio n. 12
0
    def main(self):
        """ Execute method once.
        """

        # get hardware injection in the future that is soonest
        self.hwinj = injtools.check_imminent_injection(hwinj_list, imminent_seconds)
        notify("INJECTION IMMINENT: %f"%self.hwinj.schedule_time)
        if not self.hwinj: return "FAILURE_INJECT_IN_PAST"

        # create and open an ArbitraryStream for HardwareInjection
        # this is the object from the awg module that will control
        # the injection
        try:
            self.hwinj.create_stream(ezca.ifo + ":" + exc_channel_name, sample_rate)
        except:
            etype, val, tb = sys.exc_info()
            ftb = traceback.format_tb(tb)
            for line in ftb: log(line)
            log(str(etype) + " " + str(val))
            return "FAILURE_TO_CREATE_STREAM"

        return True
Esempio n. 13
0
    def main(self):
        """ Execute method once.
        """

        # get hardware injection in the future that is soonest
        self.hwinj = injtools.check_imminent_injection(hwinj_list, imminent_seconds)
        notify("INJECTION IMMINENT: %f"%self.hwinj.schedule_time)
        if not self.hwinj: return "FAILURE_INJECT_IN_PAST"

        # legacy of the old setup to set TINJ_TYPE
        tinj_type_dict = {
            "INJECT_CBC_ACTIVE" : 1,
            "INJECT_BURST_ACTIVE" : 2,
            "INJECT_DETCHAR_ACTIVE" : 3,
            "INJECT_STOCHASTIC_ACTIVE" : 4,
        }
        ezca[type_channel_name] = tinj_type_dict[self.hwinj.schedule_state]

        # create a dict for formatting strings
        format_dict = {
            "ifo" : ezca.ifo,
        }

        # try to read waveform file
        try:
            log("Reading waveform data from %s"%self.hwinj.waveform_path.format(**format_dict))
            self.hwinj.data = self.hwinj.read_data(format_dict=format_dict)

        # if an unexpected error was encountered then jump to failure state
        except:
            etype, val, tb = sys.exc_info()
            ftb = traceback.format_tb(tb)
            for line in ftb: log(line)
            log(str(etype) + " " + str(val))
            return "FAILURE_READ_WAVEFORM"

        return True
Esempio n. 14
0
    def main(self):
        """ Execute method once.
        """

        # get hardware injection in the future that is soonest
        self.hwinj = injtools.check_imminent_injection(hwinj_list,
                                                       imminent_seconds)
        notify("INJECTION ACTIVE: %f" % self.hwinj.schedule_time)
        if not self.hwinj: return "FAILURE_INJECT_IN_PAST"

        # close stream and perform injection
        # waits for injection to finish
        try:
            self.hwinj.stream.send(self.hwinj.data)
        except:
            etype, val, tb = sys.exc_info()
            ftb = traceback.format_tb(tb)
            for line in ftb:
                log(line)
            log(str(etype) + " " + str(val))
            return "FAILURE_DURING_ACTIVE_INJECT"

        # check if stream is open when it should be closed
        if self.hwinj.stream.opened:
            self.hwinj.stream.abort()
            return "FAILURE_AWG_STREAM_NOT_CLOSED"

        # explicitly record the data from the schedule file
        log("GPS start time: %f" % self.hwinj.schedule_time)
        log("Requested state: %s" % self.hwinj.schedule_state)
        log("Requested observation mode: %d" % self.hwinj.observation_mode)
        log("Scale factor: %f" % self.hwinj.scale_factor)
        log("Waveform path: %s" % self.hwinj.waveform_path)
        log("Meta-data path: %s" % self.hwinj.metadata_path)

        return True