|
1 import os |
|
2 import plugins |
|
3 from plugins import PlugTemplate |
|
4 |
|
5 |
|
6 class PluginsRoot(PlugTemplate): |
|
7 |
|
8 # A special PlugChildsTypes |
|
9 PlugChildsTypes = [(name,lambda : getattr(__import__("plugins." + name), name).RootClass) for name in plugins.__all__] |
|
10 |
|
11 XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
|
12 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
|
13 <xsd:simpleType name="Win32Compiler"> |
|
14 <xsd:restriction base="xsd:string"> |
|
15 <xsd:enumeration value="Cygwin"/> |
|
16 <xsd:enumeration value="MinGW"/> |
|
17 <xsd:enumeration value="VC++"/> |
|
18 </xsd:restriction> |
|
19 </xsd:simpleType> |
|
20 <xsd:element name="BeremizRoot"> |
|
21 <xsd:complexType> |
|
22 <xsd:element name="TargetType"> |
|
23 <xsd:complexType> |
|
24 <xsd:choice> |
|
25 <xsd:element name="Win32"> |
|
26 <xsd:complexType> |
|
27 <xsd:attribute name="ToolChain" type="ppx:Win32Compiler" use="required" default="MinGW"/> |
|
28 <xsd:attribute name="Priority" type="xsd:integer" use="required" default="0"/> |
|
29 </xsd:complexType> |
|
30 </xsd:element> |
|
31 <xsd:element name="Linux"> |
|
32 <xsd:complexType> |
|
33 <xsd:attribute name="Compiler" type="xsd:string" use="required" default="0"/> |
|
34 <xsd:attribute name="Nice" type="xsd:integer" use="required" default="0"/> |
|
35 </xsd:complexType> |
|
36 </xsd:element> |
|
37 <xsd:element name="Xenomai"> |
|
38 <xsd:complexType> |
|
39 <xsd:attribute name="xeno-config" type="xsd:string" use="required" default="0"/> |
|
40 <xsd:attribute name="Compiler" type="xsd:string" use="required" default="0"/> |
|
41 <xsd:attribute name="Priority" type="xsd:integer" use="required" default="0"/> |
|
42 </xsd:complexType> |
|
43 </xsd:element> |
|
44 <xsd:element name="RTAI"> |
|
45 <xsd:complexType> |
|
46 <xsd:attribute name="xeno-config" type="xsd:string" use="required" default="0"/> |
|
47 <xsd:attribute name="Compiler" type="xsd:string" use="required" default="0"/> |
|
48 <xsd:attribute name="Priority" type="xsd:integer" use="required" default="0"/> |
|
49 </xsd:complexType> |
|
50 </xsd:element> |
|
51 <xsd:element name="Library"> |
|
52 <xsd:complexType> |
|
53 <xsd:attribute name="Dynamic" type="xsd:boolean" default="true"/> |
|
54 <xsd:attribute name="Compiler" type="xsd:string" use="required" default="0"/> |
|
55 </xsd:complexType> |
|
56 </xsd:element> |
|
57 </xsd:choice> |
|
58 </xsd:complexType> |
|
59 </xsd:element> |
|
60 </xsd:complexType> |
|
61 </xsd:element> |
|
62 </xsd:schema> |
|
63 """ |
|
64 |
|
65 def __init__(self, ProjectPath): |
|
66 # self is the parent |
|
67 self.PlugParent = None |
|
68 # Keep track of the plugin type name |
|
69 self.PlugType = "Beremiz" |
|
70 # Keep track of the root plugin (i.e. project path) |
|
71 self.ProjectPath = ProjectPath |
|
72 # Change XSD into class members |
|
73 self._AddParamsMembers() |
|
74 self.PluggedChilds = {} |
|
75 # No IEC channel, name, etc... |
|
76 self.MandatoryParams = [] |
|
77 # If dir have already be made, and file exist |
|
78 if os.path.isdir(_self.PlugPath(PlugName)) and os.path.isfile(_self.PluginXmlFilePath(PlugName)): |
|
79 #Load the plugin.xml file into parameters members |
|
80 _self.LoadXMLParams() |
|
81 #Load and init all the childs |
|
82 _self.LoadChilds() |
|
83 |
|
84 def PlugPath(self,PlugName=None): |
|
85 return self.ProjectPath |
|
86 |
|
87 def PluginXmlFilePath(self, PlugName=None): |
|
88 return os.path.join(self.PlugPath(PlugName), "beremiz.xml") |
|
89 |
|
90 |