Ejemplo n.º 1
0
 def getw(self, req_type=None, count=None):
     """Return a value or array of values from a channel.
     Parameters:
         req_type: database request type. Defaults to be the native data type.
         count: number of data values to read, Defaults to be the native count.
     """
     updated = [False]
     value = [0]
     def update_value(valstat):
         if valstat is None:
             return
         try:
             value[0] = valstat[0]
         finally:
             updated[0] = True
     if req_type is None: req_type = ca.dbf_type_to_DBR(self.field_type())
     if count is None: count = 0
     try:
         ca.get(self.__chid, update_value, req_type, count)
     except ca.error,msg:
         raise CaChannelException,msg
Ejemplo n.º 2
0
 def array_get_callback(self, req_type, count, callback, *user_args):
     """Read a value or array of values from a channel and execute the user
     supplied callback after the get has completed.
     Parameters:
         req_type: database request type. Defaults to be the native data type.
         count: number of data values to read, Defaults to be the native count.
         callback: function called when the get is completed.
         *user_args: user provided arguments that are passed to callback when
         it is invoked.
     >>> def getCB(epicsArgs, userArgs):
     ...     for item in sorted(epicsArgs.keys()):
     ...         if item.startswith('pv_'):
     ...             print item,epicsArgs[item]
     >>> chan = CaChannel('catest')
     >>> chan.searchw()
     >>> chan.putw(145)
     >>> chan.array_get_callback(ca.DBR_CTRL_DOUBLE, 1, getCB)
     >>> status = chan.pend_event(1)
     pv_loalarmlim -20.0
     pv_loctrllim 0.0
     pv_lodislim 0.0
     pv_lowarnlim -10.0
     pv_precision 3
     pv_seconds 0.0
     pv_severity 2
     pv_status 3
     pv_units mm
     pv_upalarmlim 20.0
     pv_upctrllim 0.0
     pv_updislim 0.0
     pv_upwarnlim 10.0
     pv_value 145.0
     >>> chan = CaChannel('cabo')
     >>> chan.searchw()
     >>> chan.putw(0)
     >>> chan.array_get_callback(ca.DBR_CTRL_ENUM, 1, getCB)
     >>> status = chan.pend_event(1)
     pv_nostrings 2
     pv_seconds 0.0
     pv_severity 0
     pv_statestrings ('Done', 'Busy')
     pv_status 0
     pv_value 0
     """
     if req_type is None: req_type = ca.dbf_type_to_DBR(self.field_type())
     if count is None: count = 0
     self._callbacks['getCB']=(callback, user_args)
     try:
         status=ca.get(self.__chid, self._get_callback, req_type, count)
     except ca.error,msg:
         raise CaChannelException,msg
Ejemplo n.º 3
0
 def array_get_callback(self, req_type, count, callback, *user_args):
     """Read a value or array of values from a channel and execute the user
     supplied callback after the get has completed.
     Parameters:
         req_type: database request type. Defaults to be the native data type.
         count: number of data values to read, Defaults to be the native count.
         callback: function called when the get is completed.
         *user_args: user provided arguments that are passed to callback when
         it is invoked.
     >>> def getCB(epicsArgs, userArgs):
     ...     for item in sorted(epicsArgs.keys()):
     ...         if item.startswith('pv_'):
     ...             print item,epicsArgs[item]
     >>> chan = CaChannel('catest')
     >>> chan.searchw()
     >>> chan.putw(145)
     >>> chan.array_get_callback(ca.DBR_CTRL_DOUBLE, 1, getCB)
     >>> status = chan.pend_event(1)
     pv_loalarmlim -20.0
     pv_loctrllim 0.0
     pv_lodislim 0.0
     pv_lowarnlim -10.0
     pv_precision 3
     pv_seconds 0.0
     pv_severity 2
     pv_status 3
     pv_units mm
     pv_upalarmlim 20.0
     pv_upctrllim 0.0
     pv_updislim 0.0
     pv_upwarnlim 10.0
     pv_value 145.0
     >>> chan = CaChannel('cabo')
     >>> chan.searchw()
     >>> chan.putw(0)
     >>> chan.array_get_callback(ca.DBR_CTRL_ENUM, 1, getCB)
     >>> status = chan.pend_event(1)
     pv_nostrings 2
     pv_seconds 0.0
     pv_severity 0
     pv_statestrings ('Done', 'Busy')
     pv_status 0
     pv_value 0
     """
     if req_type is None: req_type = ca.dbf_type_to_DBR(self.field_type())
     if count is None: count = 0
     self._callbacks['getCB'] = (callback, user_args)
     try:
         status = ca.get(self.__chid, self._get_callback, req_type, count)
     except ca.error, msg:
         raise CaChannelException, msg
Ejemplo n.º 4
0
    def getw(self, req_type=None, count=None):
        """Return a value or array of values from a channel.
        Parameters:
            req_type: database request type. Defaults to be the native data type.
            count: number of data values to read, Defaults to be the native count.
        """
        updated = [False]
        value = [0]

        def update_value(valstat):
            if valstat is None:
                return
            try:
                value[0] = valstat[0]
            finally:
                updated[0] = True

        if req_type is None: req_type = ca.dbf_type_to_DBR(self.field_type())
        if count is None: count = 0
        try:
            ca.get(self.__chid, update_value, req_type, count)
        except ca.error, msg:
            raise CaChannelException, msg