Example #1
0
    def __RefreshPageOrig (source_obj,self,page):
        """
        Virtual method, implements seeking for changes in data.
        Returns non-zero if the page was changed.
        If not implemented in the derived class, this class doesn't
        support dinamic changes monitoring.
        As pages can be copied to different Data objects, and can
        store the original RefreshPage method for updating, source_obj
        refers to the object that was origin of the page data, while
        self indicates the object that actually owns the page
        with index page.
        It was done this way because if it is stored the reference to
        the unbound method, python doesn't allow you to call it with
        an object of different data type.

        Important:
        Derived classes shall update the page:   self.Pages[page]
        but not:   source_obj.Pages[page]
        """       
        if (self.GetItemPageInfo("SourceType",page)==SOURCE_TYPE):
            specname=self.GetItemPageInfo("SourceName",page)
            arrayname=self.GetItemPageInfo("Key",page)
            updatecounter=self.GetItemPageInfo("updatecounter",page)
            if (updatecounter!=None) and (arrayname!=None) and (specname!=None):
                if specname in sps.getspeclist():
                    if arrayname in sps.getarraylist(specname):
                        counter=sps.updatecounter (specname,arrayname)
                        if (counter != updatecounter):
                            info=self.GetPageInfo(page)
                            info.update(self.__GetArrayInfo(arrayname))
                            if   info["row"]!="ALL": data= sps.getdatarow(specname,arrayname,info["row"])
                            elif info["col"]!="ALL": data= sps.getdatacol(specname,arrayname,info["col"])
                            else: data=sps.getdata (specname,arrayname)                            
                            self.Pages[page].Array=data
                            return 1
            infoname= self.GetItemPageInfo("EnvKey")
            infoupdc= self.GetItemPageInfo("env_updatecounter")
            if (infoupdc!=None) and (infoname!=None) and (specname!=None):
                if infoname in sps.getarraylist(specname):
                    counter= sps.updatecounter(specname,infoname)
                    if (counter!=infoupdc):
                        info= self.GetPageInfo(page)
                        info.update(self.__GetArrayInfo(arrayname))
                        return 1
        return 0
Example #2
0
    def __RefreshPageOrig (source_obj,self,page):
        """
        Virtual method, implements seeking for changes in data.
        Returns non-zero if the page was changed.
        If not implemented in the derived class, this class doesn't
        support dinamic changes monitoring.
        As pages can be copied to different Data objects, and can
        store the original RefreshPage method for updating, source_obj
        refers to the object that was origin of the page data, while
        self indicates the object that actually owns the page
        with index page.
        It was done this way because if it is stored the reference to
        the unbound method, python doesn't allow you to call it with
        an object of different data type.

        Important:
        Derived classes shall update the page:   self.Pages[page]
        but not:   source_obj.Pages[page]
        """
        if (self.GetItemPageInfo("SourceType",page)==SOURCE_TYPE):
            specname=self.GetItemPageInfo("SourceName",page)
            arrayname=self.GetItemPageInfo("Key",page)
            updatecounter=self.GetItemPageInfo("updatecounter",page)
            if (updatecounter!=None) and (arrayname!=None) and (specname!=None):
                if specname in sps.getspeclist():
                    if arrayname in sps.getarraylist(specname):
                        counter=sps.updatecounter (specname,arrayname)
                        if (counter != updatecounter):
                            info=self.GetPageInfo(page)
                            info.update(self.__GetArrayInfo(arrayname))
                            if   info["row"]!="ALL": data= sps.getdatarow(specname,arrayname,info["row"])
                            elif info["col"]!="ALL": data= sps.getdatacol(specname,arrayname,info["col"])
                            else: data=sps.getdata (specname,arrayname)
                            self.Pages[page].Array=data
                            return 1
            infoname= self.GetItemPageInfo("EnvKey")
            infoupdc= self.GetItemPageInfo("env_updatecounter")
            if (infoupdc!=None) and (infoname!=None) and (specname!=None):
                if infoname in sps.getarraylist(specname):
                    counter= sps.updatecounter(specname,infoname)
                    if (counter!=infoupdc):
                        info= self.GetPageInfo(page)
                        info.update(self.__GetArrayInfo(arrayname))
                        return 1
        return 0
Example #3
0
 def LoadSource(self,key_list="ALL",append=0,invalidate=1,row="ALL",col="ALL"):
     """
     Creates a given number of pages, getting data from the actual
     source (set by SetSource)
     Parameters:
     key_list: list of all keys to be read from source. It is a list of
              string, shared memory array names, to be read from the file.
              It can be also one single string, if only one array is to be read.
     append: If non-zero appends to the end of page list.
             Otherwise, initializes the page list                
     invalidate: if non-zero performas an invalidade call after
                 loading
     row: If set to an integer, loads a single row (0-based indexed)
     col: If set to an integer, loads a single column (0-based indexed)
     """
     #AS if append==0: Data.Delete(self)        
     if type(key_list) == type(" "): key_list=(key_list,)
     output =[]
     if self.SourceName in sps.getspeclist():
         if key_list == "ALL":
             key_list = sps.getarraylist(self.SourceName)
         for array in key_list:
             if array in sps.getarraylist(self.SourceName):
                 info = self.__GetArrayInfo(array)
                 info["row"] = row
                 info["col"] = col
                 if info["row"]!="ALL":
                     data= sps.getdatarow(self.SourceName, array,info["row"])
                     if data is not None:
                         data=numpy.reshape(data,(1, data.shape[0]))
                 elif info["col"]!="ALL":
                     data= sps.getdatacol(self.SourceName, array, info["col"])
                     if data is not None:
                         data=numpy.reshape(data, (data.shape[0], 1))
                 else:
                     data=sps.getdata (self.SourceName, array)
                 #self.AppendPage(info,data)
                 output.append([info,data])
     if len(output) == 1:
         return output[0]
     else:
         return output
Example #4
0
 def LoadSource(self,key_list="ALL",append=0,invalidate=1,row="ALL",col="ALL"):
     """
     Creates a given number of pages, getting data from the actual
     source (set by SetSource)
     Parameters:
     key_list: list of all keys to be read from source. It is a list of
              string, shared memory array names, to be read from the file.
              It can be also one single string, if only one array is to be read.
     append: If non-zero appends to the end of page list.
             Otherwise, initializes the page list
     invalidate: if non-zero performas an invalidade call after
                 loading
     row: If set to an integer, loads a single row (0-based indexed)
     col: If set to an integer, loads a single column (0-based indexed)
     """
     #AS if append==0: Data.Delete(self)
     if type(key_list) == type(" "): key_list=(key_list,)
     output =[]
     if self.SourceName in sps.getspeclist():
         if key_list == "ALL":
             key_list = sps.getarraylist(self.SourceName)
         for array in key_list:
             if array in sps.getarraylist(self.SourceName):
                 info = self.__GetArrayInfo(array)
                 info["row"] = row
                 info["col"] = col
                 if info["row"]!="ALL":
                     data= sps.getdatarow(self.SourceName, array,info["row"])
                     if data is not None:
                         data=numpy.reshape(data,(1, data.shape[0]))
                 elif info["col"]!="ALL":
                     data= sps.getdatacol(self.SourceName, array, info["col"])
                     if data is not None:
                         data=numpy.reshape(data, (data.shape[0], 1))
                 else:
                     data=sps.getdata (self.SourceName, array)
                 #self.AppendPage(info,data)
                 output.append([info,data])
     if len(output) == 1:
         return output[0]
     else:
         return output