示例#1
0
文件: driver.py 项目: gitcyc/pcaspy
 def __init__(self):
     self.value = 0
     self.flag  = False
     self.severity  = Severity.INVALID_ALARM
     self.alarm = Alarm.UDF_ALARM
     self.udf = True
     self.mask = 0
     self.time  = cas.epicsTimeStamp()
示例#2
0
文件: driver.py 项目: gitcyc/pcaspy
    def setParamValue(self, reason, value):
        """set PV value and request update

        :param str reason:
        :param value: new value
        """
        # check whether update is needed
        same = self.pvDB[reason].value == value
        if (type(same) == bool and not same) or (hasattr(same, 'all') and not same.all()):
            # make a copy of mutable objects, list, numpy.ndarray
            if isinstance(value, list):
                value = value[:]
            elif str(type(value)) == "<type 'numpy.ndarray'>":
                value = value.copy()
            self.pvDB[reason].value = value
            self.pvDB[reason].flag = True
            self.pvDB[reason].mask = (cas.DBE_VALUE | cas.DBE_LOG)
        self.pvDB[reason].time = cas.epicsTimeStamp()
示例#3
0
    def setParam(self, reason, value):
        """set PV value and request update

        :param str reason: PV base name
        :param value: PV new value

        Store the PV's new value if it is indeed different from the old.
        For list and numpy array, a copy will be made.
        This new value will be pushed to registered client the next time when :meth:`updatePVs` is called.
        The timestamp will be updated to the current time anyway.

        Alarm and severity status are updated as well. For numeric type, the alarm/severity is determined as the
        following:

            ========================    ============  ============
            value                       alarm         severity
            ========================    ============  ============
            value < *lolo*              LOLO_ALARM    MAJOR_ALARM
            *lolo* < value < *low*      LOW_ALARM     MINOR_ALARM
            *low* < value < *high*      NO_ALARM      NO_ALARM
            *high* < value < *hihi*     HIGH_ALARM    MINOR_ALARM
            value > *hihi*              HIHI_ALARM    MAJOR_ALARM
            ========================    ============  ============

        For enumerate type, the alarm severity is defined by field *states*. And if severity is other than NO_ALARM,
        the alarm status is STATE_ALARM.

        """
        # check whether update is needed
        same = self.pvDB[reason].value == value
        if (type(same) == bool and not same) or (hasattr(same, 'all') and not same.all()):
            # make a copy of mutable objects, list, numpy.ndarray
            if isinstance(value, list):
                value = value[:]
            elif str(type(value)) == "<type 'numpy.ndarray'>":
                value = value.copy()
            self.pvDB[reason].value = value
            self.pvDB[reason].flag  = True
        self.pvDB[reason].time = cas.epicsTimeStamp()
        alarm, severity = self._checkAlarm(reason, value)
        if alarm is not None: self.pvDB[reason].alarm = alarm
        if severity is not None: self.pvDB[reason].severity = severity
        logging.getLogger('pcaspy.Driver.setParam')\
            .debug('%s: %s', reason, self.pvDB[reason])
示例#4
0
 def __init__(self):
     self.value = 0
     self.flag  = False
     self.severity  = Severity.INVALID_ALARM
     self.alarm = Alarm.UDF_ALARM
     self.time  = cas.epicsTimeStamp()