Пример #1
0
    def saveSnapshot(self, params):
        """
        This function is to take a machine snapshot data and send data to client for preview . 
        Meanwhile the data will be saved into database with a default flag to identify 
        that this preview is not approved by the user yet.
        It gives user a opportunity to confirm whether the snapshot is good or not.
        
        It creates an entry in both event list table, and event data table.
 
        Parameters: a dictionary which can have any combination of the following predefined keys:
                    'servicename': [optional] exact service name if given
                    'configname':  exact configuration name
                    'comment':     [optional] exact comment. 

        result:     list of list with the following format:
                    id:                  id of this new event
                    pv name []:          pv name list
                    value []             value list
                    dbrTypee []          EPICS V3 DBR type for each channel
                    isConnected []:      connection status, either True or False
                    secondsPastEpoch []: seconds after EPOCH time
                    nanoSeconds []:      nano-seconds
                    userTags []:
                    alarmSeverity []:    EPICS IOC severity
                    alarmStatus []:      EPICS IOC status
                    alarmMessage []:     EPICS IOC pv status message

                    otherwise, False if nothing is found.
        """
        function = 'saveSnapshot'
        ntmultichannels = self.__clientRPC(function, params)

        # check fault
        if not isinstance(ntmultichannels, NTMultiChannel):
            raise RuntimeError("Wrong returned data type")
        if ntmultichannels.getNumberChannel() == 0:
            # No returned value. 
            return False

        ts = TimeStamp()
        ntmultichannels.getTimeStamp(ts)
        # [pv name, value,
        #  isConnected, secondsPastEpoch, nanoSeconds, timeStampTag,
        #  alarmSeverity, alarmStatus, alarmMessage]
        return (ts.getUserTag(),
                ntmultichannels.getChannelName(),
                ntmultichannels.getValue(),
                ntmultichannels.getDbrType(),
                ntmultichannels.getIsConnected(),
                ntmultichannels.getSecondsPastEpoch(),
                ntmultichannels.getNanoseconds(),
                ntmultichannels.getUserTag(),
                ntmultichannels.getSeverity(),
                ntmultichannels.getStatus(),
                ntmultichannels.getMessage())
Пример #2
0
    def saveSnapshot(self, params):
        """
        This function is to take a machine snapshot data and send data to client for preview . 
        Meanwhile the data will be saved into database with a default flag to identify 
        that this preview is not approved by the user yet.
        It gives user a opportunity to confirm whether the snapshot is good or not.
        
        It creates an entry in both event list table, and event data table.
 
        Parameters: a dictionary which can have any combination of the following predefined keys:
                    'servicename': [optional] exact service name if given
                    'configname':  exact configuration name
                    'comment':     [optional] exact comment. 

        result:     list of list with the following format:
                    id: id of this new event
                    pv name []:          pv name list
                    string value []:     value list in string format
                    double value []      value list in double format
                    long value []        value list in long format
                    dbr_type []:         EPICS DBR types
                    isConnected []:      connection status, either True or False
                    secondsPastEpoch []: seconds after EPOCH time
                    nanoSeconds []:      nano-seconds
                    alarmSeverity []:    EPICS IOC severity
                    alarmStatus []:      EPICS IOC status
                    is_array []:         whether value is array, either True or False
                    array_value [[]]:    if it is array, the value is stored here.
                            
                    otherwise, False if operation failed.
        """
        function = 'saveSnapshot'
        nttable = self.__clientRPC(function, params)

        if self.__isFault(nttable):
            return False
        
        ts = TimeStamp()
        # [pv name,string value,double value,long value,
        #  dbr type,isConnected,secondsPastEpoch,nanoSeconds,timeStampTag,
        #  alarmSeverity,alarmStatus,alarmMessage, is_array, array_value]
        nttable.getTimeStamp(ts.getTimeStampPy())
        return (ts.getUserTag(),
                nttable.getValue(0), 
                nttable.getValue(1), 
                nttable.getValue(2),
                nttable.getValue(3),
                nttable.getValue(4),
                nttable.getValue(5),
                nttable.getValue(6),
                nttable.getValue(7),
                nttable.getValue(9),
                nttable.getValue(10),
                nttable.getValue(12),
                nttable.getValue(13))
Пример #3
0
    def saveSnapshot(self, params):
        """
        This function is to take a machine snapshot data and send data to client for preview . 
        Meanwhile the data will be saved into database with a default flag to identify 
        that this preview is not approved by the user yet.
        It gives user a opportunity to confirm whether the snapshot is good or not.
        
        It creates an entry in both event list table, and event data table.
 
        Parameters: a dictionary which can have any combination of the following predefined keys:
                    'servicename': [optional] exact service name if given
                    'configname':  exact configuration name
                    'comment':     [optional] exact comment. 

        result:     list of list with the following format:
                    id:                  id of this new event
                    pv name []:          pv name list
                    value []             value list
                    dbrTypee []          EPICS V3 DBR type for each channel
                    isConnected []:      connection status, either True or False
                    secondsPastEpoch []: seconds after EPOCH time
                    nanoSeconds []:      nano-seconds
                    userTags []:
                    alarmSeverity []:    EPICS IOC severity
                    alarmStatus []:      EPICS IOC status
                    alarmMessage []:     EPICS IOC pv status message

                    otherwise, False if nothing is found.
        """
        function = 'saveSnapshot'
        ntmultichannels = self.__clientRPC(function, params)

        # check fault
        if not isinstance(ntmultichannels, NTMultiChannel):
            raise RuntimeError("Wrong returned data type")
        if ntmultichannels.getNumberChannel() == 0:
            # No returned value.
            return False

        ts = TimeStamp()
        ntmultichannels.getTimeStamp(ts)
        # [pv name, value,
        #  isConnected, secondsPastEpoch, nanoSeconds, timeStampTag,
        #  alarmSeverity, alarmStatus, alarmMessage]
        return (ts.getUserTag(), ntmultichannels.getChannelName(),
                ntmultichannels.getValue(), ntmultichannels.getDbrType(),
                ntmultichannels.getIsConnected(),
                ntmultichannels.getSecondsPastEpoch(),
                ntmultichannels.getNanoseconds(), ntmultichannels.getUserTag(),
                ntmultichannels.getSeverity(), ntmultichannels.getStatus(),
                ntmultichannels.getMessage())
Пример #4
0
    def __clientRPC(self, function, params, conn_time=1.0, resp_time=5.0):
        """
        internal library for pvAccess channel RPC.
        
        conn_time: waiting time for connection, 1.0 by default;
        resp_time: waiting time for response, 5.0 by default
        """
        alarm = Alarm()
        timeStamp = TimeStamp()

        ntnv = NTNameValue(function, params)

        # now do issue + wait
        channelRPC = ChannelRPC(self.channelname)
        channelRPC.issueConnect()
        if not channelRPC.waitConnect(conn_time):
            #print channelRPC.getMessage()
            raise Exception(channelRPC.getMessage())
        channelRPC.issueRequest(ntnv.getNTNameValue(), False)
        result = channelRPC.waitResponse(resp_time)
        if result is None:
            #print channelRPC.getMessage()
            raise Exception(channelRPC.getMessage())
        if function in ["retrieveSnapshot", "getLiveMachine", "saveSnapshot"]:
            result = NTMultiChannel(result)
        elif function in [
                "retrieveServiceEvents", "retrieveServiceConfigs",
                "retrieveServiceConfigProps"
        ]:
            result = NTTable(result)
        elif function == "updateSnapshotEvent":
            result = NTScalar(result)
        result.getAlarm(alarm)
        result.getTimeStamp(timeStamp)
        return result
Пример #5
0
 def __clientRPC(self, function, params):
     """
     internal library for pvAccess channel RPC.
     """
     alarm = Alarm()
     timeStamp = TimeStamp()
 
     ntnv = NTNameValue(function,params)
     
     # now do issue + wait
     channelRPC = ChannelRPC(self.channelname,"record[process=true]field()")
     channelRPC.issueConnect()
     if not channelRPC.waitConnect(1.0) :
         print channelRPC.getMessage()
         raise Exception(channelRPC.getMessage())
     channelRPC.issueRequest(ntnv.getNTNameValue(),False)
     result = channelRPC.waitRequest()
     if(result==None) :
         print channelRPC.getMessage()
         raise Exception(channelRPC.getMessage())
     nttable = NTTable(result)
     nttable.getAlarm(alarm.getAlarmPy())    
     nttable.getTimeStamp(timeStamp.getTimeStampPy())
     return nttable