LPCManager.py
changeset 4 e8a0af6b89d9
parent 2 0c697b8fc443
child 5 7a09e12267a9
child 6 8863b78144ee
equal deleted inserted replaced
2:0c697b8fc443 4:e8a0af6b89d9
    68 connectors.connectors["LPC"]=lambda:LPC_connector_factory
    68 connectors.connectors["LPC"]=lambda:LPC_connector_factory
    69 
    69 
    70 import targets
    70 import targets
    71 from LPCtarget import LPC_target 
    71 from LPCtarget import LPC_target 
    72 targets.targets["LPC"] = {"xsd": os.path.join(_base_path, "LPCtarget", "XSD"),
    72 targets.targets["LPC"] = {"xsd": os.path.join(_base_path, "LPCtarget", "XSD"),
    73                           "class": lambda:LPC_target,
    73                           "class": lambda: LPC_target,
    74                           "code": os.path.join(_base_path,"LPCtarget","plc_LPC_main.c")} 
    74                           "code": os.path.join(_base_path,"LPCtarget","plc_LPC_main.c")} 
    75 targets.toolchains["makefile"] = os.path.join(_base_path, "LPCtarget", "XSD_toolchain_makefile")
    75 targets.toolchains["makefile"] = os.path.join(_base_path, "LPCtarget", "XSD_toolchain_makefile")
    76 
    76 
    77 # helper func to get path to images
    77 # helper func to get path to images
    78 from util import misc
    78 from util import misc
    79 misc.opjimg = lambda imgname: os.path.join(_base_folder, "beremiz", "images", imgname+".png")
    79 misc.opjimg = lambda imgname: os.path.join(_base_folder, "beremiz", "images", imgname+".png")
    80 
    80 
    81 from Beremiz import *
    81 from Beremiz import *
       
    82 
       
    83 import features
       
    84 from POULibrary import POULibrary
       
    85 
       
    86 class PLCLibrary(POULibrary):
       
    87     def GetLibraryPath(self):
       
    88         return os.path.join(_base_path, "pous.xml")
       
    89 
       
    90 features.libraries.append(
       
    91     ('LPC', lambda: PLCLibrary))
       
    92 
    82 from ProjectController import ProjectController
    93 from ProjectController import ProjectController
    83 from ConfigTreeNode import ConfigTreeNode
    94 from ConfigTreeNode import ConfigTreeNode
    84 from ProjectNodeEditor import ProjectNodeEditor
    95 from ProjectNodeEditor import ProjectNodeEditor
    85 
    96 
    86 from plcopen.structures import LOCATIONDATATYPES
    97 from plcopen.structures import LOCATIONDATATYPES
   581         def LoadChildren(self):
   592         def LoadChildren(self):
   582             ConfigTreeNode.LoadChildren(self)
   593             ConfigTreeNode.LoadChildren(self)
   583             
   594             
   584             if self.GetChildByName("Master") is None:
   595             if self.GetChildByName("Master") is None:
   585                 master = self.CTNAddChild("Master", "CanOpenNode", 0)
   596                 master = self.CTNAddChild("Master", "CanOpenNode", 0)
   586                 master.BaseParams.setEnabled(False)
   597                 #master.BaseParams.setEnabled(False)
   587                 master.CTNRequestSave()
   598                 master.CTNRequestSave()
   588             
   599             
   589             if self.GetChildByName("Slave") is None:
   600             if self.GetChildByName("Slave") is None:
   590                 slave = self.CTNAddChild("Slave", "CanOpenSlave", 1)
   601                 slave = self.CTNAddChild("Slave", "CanOpenSlave", 1)
   591                 slave.BaseParams.setEnabled(False)
   602                 #slave.BaseParams.setEnabled(False)
   592                 slave.CTNRequestSave()
   603                 slave.CTNRequestSave()
   593     
   604     
   594 
   605 
   595 #-------------------------------------------------------------------------------
   606 #-------------------------------------------------------------------------------
   596 #                              LPCProjectController Class
   607 #                              LPCProjectController Class
   601     Copy content of a directory to an other, omit hidden files
   612     Copy content of a directory to an other, omit hidden files
   602     @param src: source directory
   613     @param src: source directory
   603     @param dst: destination directory
   614     @param dst: destination directory
   604     """
   615     """
   605     for i in os.listdir(src):
   616     for i in os.listdir(src):
   606         if not i.startswith('.') and i != "pous.xml":
   617         if not i.startswith('.'):
   607             srcpath = os.path.join(src,i)
   618             srcpath = os.path.join(src,i)
   608             dstpath = os.path.join(dst,i)
   619             dstpath = os.path.join(dst,i)
   609             if os.path.isdir(srcpath):
   620             if os.path.isdir(srcpath):
   610                 if os.path.exists(dstpath):
   621                 if os.path.exists(dstpath):
   611                     shutil.rmtree(dstpath)
   622                     shutil.rmtree(dstpath)
   684                 resources["values"].extend(config_infos["values"][0]["values"])
   695                 resources["values"].extend(config_infos["values"][0]["values"])
   685         if resources is not None:
   696         if resources is not None:
   686             infos["values"].append(resources)
   697             infos["values"].append(resources)
   687         return infos
   698         return infos
   688     
   699     
   689     def ConfNodeLibraryFilePath(self):
       
   690         if self.OrigBuildPath is not None:
       
   691             return os.path.join(self.OrigBuildPath, "pous.xml")
       
   692         else:
       
   693             return ProjectController.ConfNodeLibraryFilePath(self)
       
   694     
       
   695     def GetProjectName(self):
   700     def GetProjectName(self):
   696         return self.Project.getname()
   701         return self.Project.getname()
   697 
   702 
   698     def GetDefaultTargetName(self):
   703     def GetDefaultTargetName(self):
   699         if self.CurrentMode == SIMULATION_MODE:
   704         if self.CurrentMode == SIMULATION_MODE:
   852             #Load and init all the children
   857             #Load and init all the children
   853             self.LoadChildren()
   858             self.LoadChildren()
   854         
   859         
   855         if havecanfestival and self.GetChildByName("CanOpen") is None:
   860         if havecanfestival and self.GetChildByName("CanOpen") is None:
   856             canopen = self.CTNAddChild("CanOpen", "CanOpen", 0)
   861             canopen = self.CTNAddChild("CanOpen", "CanOpen", 0)
   857             canopen.BaseParams.setEnabled(False)
   862             #canopen.BaseParams.setEnabled(False)
   858             canopen.LoadChildren()
   863             canopen.LoadChildren()
   859             canopen.CTNRequestSave()
   864             canopen.CTNRequestSave()
   860         
   865         
   861         if self.CTNTestModified():
   866         if self.CTNTestModified():
   862             self.SaveProject()
   867             self.SaveProject()
  1487         leftwindow.SetSizer(leftwindowvsizer)
  1492         leftwindow.SetSizer(leftwindowvsizer)
  1488         
  1493         
  1489         leftwindowsizer = wx.BoxSizer(wx.HORIZONTAL)
  1494         leftwindowsizer = wx.BoxSizer(wx.HORIZONTAL)
  1490         leftwindowvsizer.AddSizer(leftwindowsizer, 0, border=0, flag=0)
  1495         leftwindowvsizer.AddSizer(leftwindowsizer, 0, border=0, flag=0)
  1491         
  1496         
  1492         self.GenerateEnableButton(leftwindow, leftwindowsizer, confnode)
  1497         #self.GenerateEnableButton(leftwindow, leftwindowsizer, confnode)
  1493         
  1498         
  1494         st = wx.StaticText(leftwindow, -1)
  1499         st = wx.StaticText(leftwindow, -1)
  1495         st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"]))
  1500         st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"]))
  1496         st.SetLabel(confnode.GetFullIEC_Channel())
  1501         st.SetLabel(confnode.GetFullIEC_Channel())
  1497         leftwindowsizer.AddWindow(st, 0, border=5, flag=wx.RIGHT)
  1502         leftwindowsizer.AddWindow(st, 0, border=5, flag=wx.LEFT|wx.RIGHT)
  1498         
  1503         
  1499         expandbutton_id = wx.NewId()
  1504         expandbutton_id = wx.NewId()
  1500         expandbutton = wx.lib.buttons.GenBitmapToggleButton(id=expandbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'plus.png')),
  1505         expandbutton = wx.lib.buttons.GenBitmapToggleButton(id=expandbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'plus.png')),
  1501               name='ExpandButton', parent=leftwindow, pos=wx.Point(0, 0),
  1506               name='ExpandButton', parent=leftwindow, pos=wx.Point(0, 0),
  1502               size=wx.Size(13, 13), style=wx.NO_BORDER)
  1507               size=wx.Size(13, 13), style=wx.NO_BORDER)