plugger.py
changeset 401 8106a853a7c7
parent 396 d1083f580ca1
child 402 984e238e63d0
equal deleted inserted replaced
400:2c786431fe72 401:8106a853a7c7
    14 
    14 
    15 from docpdf import *
    15 from docpdf import *
    16 from xmlclass import GenerateClassesFromXSDstring
    16 from xmlclass import GenerateClassesFromXSDstring
    17 from wxPopen import ProcessLogger
    17 from wxPopen import ProcessLogger
    18 
    18 
    19 from PLCControler import PLCControler
    19 from PLCControler import PLCControler, LOCATION_PLUGIN, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY
    20 
    20 
    21 _BaseParamsClass = GenerateClassesFromXSDstring("""<?xml version="1.0" encoding="ISO-8859-1" ?>
    21 _BaseParamsClass = GenerateClassesFromXSDstring("""<?xml version="1.0" encoding="ISO-8859-1" ?>
    22         <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    22         <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    23           <xsd:element name="BaseParams">
    23           <xsd:element name="BaseParams">
    24             <xsd:complexType>
    24             <xsd:complexType>
   365         return ".".join([str(i) for i in self.GetCurrentLocation()]) + ".x"
   365         return ".".join([str(i) for i in self.GetCurrentLocation()]) + ".x"
   366 
   366 
   367     def GetLocations(self):
   367     def GetLocations(self):
   368         location = self.GetCurrentLocation()
   368         location = self.GetCurrentLocation()
   369         return [loc for loc in self.PlugParent.GetLocations() if loc["LOC"][0:len(location)] == location]
   369         return [loc for loc in self.PlugParent.GetLocations() if loc["LOC"][0:len(location)] == location]
       
   370 
       
   371     def GetVariableLocationTree(self):
       
   372         '''
       
   373         This function is meant to be overridden by plugins.
       
   374 
       
   375         It should returns an list of dictionaries
       
   376         
       
   377         - IEC_type is an IEC type like BOOL/BYTE/SINT/...
       
   378         - location is a string of this variable's location, like "%IX0.0.0"
       
   379         '''
       
   380         children = []
       
   381         for child in self.IECSortedChilds():
       
   382             children.append({"name": child.BaseParams.getName(),
       
   383                              "type": LOCATION_PLUGIN,
       
   384                              "children": child.GetVariableLocationTree()})
       
   385         return children
   370 
   386 
   371     def GetPlugInfos(self):
   387     def GetPlugInfos(self):
   372         childs = []
   388         childs = []
   373         # reorder childs by IEC_channels
   389         # reorder childs by IEC_channels
   374         for child in self.IECSortedChilds():
   390         for child in self.IECSortedChilds():
   877             self.ClearPluginTypes()
   893             self.ClearPluginTypes()
   878             self.AddPluginBlockList(self.PluginsBlockTypesFactory())
   894             self.AddPluginBlockList(self.PluginsBlockTypesFactory())
   879         if self.AppFrame is not None:
   895         if self.AppFrame is not None:
   880             self.AppFrame.RefreshLibraryTree()
   896             self.AppFrame.RefreshLibraryTree()
   881             self.AppFrame.RefreshEditor()
   897             self.AppFrame.RefreshEditor()
       
   898     
       
   899     def GetVariableLocationTree(self):
       
   900         return PlugTemplate.GetVariableLocationTree(self)
   882     
   901     
   883     def PluginPath(self):
   902     def PluginPath(self):
   884         return os.path.join(os.path.split(__file__)[0], "plugins")
   903         return os.path.join(os.path.split(__file__)[0], "plugins")
   885     
   904     
   886     def PlugPath(self, PlugName=None):
   905     def PlugPath(self, PlugName=None):