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))
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