12
|
1 |
import os
|
11
|
2 |
from nodelist import NodeList
|
|
3 |
from nodemanager import NodeManager
|
|
4 |
import config_utils, gen_cfile
|
12
|
5 |
from networkedit import networkedit
|
11
|
6 |
|
12
|
7 |
class _NetworkEditPlugg(networkedit):
|
|
8 |
def OnCloseFrame(self, event):
|
|
9 |
self.OnPluggClose()
|
|
10 |
event.Skip()
|
|
11 |
|
|
12 |
class BusController(NodeList):
|
|
13 |
XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
|
|
14 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
|
15 |
<xsd:element name="CanFestivalNode">
|
|
16 |
<xsd:complexType>
|
|
17 |
<xsd:attribute name="CAN_Device" type="xsd:string" use="required" />
|
|
18 |
</xsd:complexType>
|
|
19 |
</xsd:element>
|
|
20 |
</xsd:schema>
|
|
21 |
"""
|
|
22 |
|
|
23 |
ViewClass = _NetworkEditPlugg
|
|
24 |
|
|
25 |
def __init__(self, buspath):
|
11
|
26 |
manager = NodeManager()
|
|
27 |
NodeList.__init__(self, manager)
|
|
28 |
self.LoadProject(buspath)
|
|
29 |
|
12
|
30 |
def TestModified(self):
|
|
31 |
return self.HasChanged()
|
|
32 |
|
|
33 |
def ReqSave(self):
|
11
|
34 |
self.SaveProject()
|
12
|
35 |
return True
|
|
36 |
|
|
37 |
def Generate_C(self, dirpath, locations):
|
|
38 |
"""
|
|
39 |
return C code for network dictionnary
|
|
40 |
"""
|
|
41 |
filepath = os.path.join(dirpath, "master.c")
|
|
42 |
master = config_utils.GenerateConciseDCF(locations, self)
|
|
43 |
res = gen_cfile.GenerateFile(filepath, master)
|
|
44 |
if not res:
|
|
45 |
s = str(self.BaseParams.BusId)+"_IN(){}\n"
|
|
46 |
s += "CanOpen(str(\""+self.CanFestivalNode.CAN_Device)+"\")"
|
|
47 |
f = file(filepath, 'a')
|
|
48 |
f.write(s)
|
|
49 |
else:
|
|
50 |
pass # error
|
|
51 |
return {"headers":["master.h"],"sources":["master.c"]}
|
|
52 |
|
|
53 |
class PluginController:
|
|
54 |
XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
|
|
55 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
|
56 |
<xsd:element name="CanFestivalInstance">
|
|
57 |
<xsd:complexType>
|
|
58 |
<xsd:attribute name="CAN_Driver" type="xsd:string" use="required" />
|
|
59 |
</xsd:complexType>
|
|
60 |
</xsd:element>
|
|
61 |
</xsd:schema>
|
|
62 |
"""
|
11
|
63 |
|
|
64 |
def Generate_C(self, filepath, locations):
|
|
65 |
"""
|
|
66 |
return C code for network dictionnary
|
|
67 |
"""
|
|
68 |
master = config_utils.GenerateConciseDCF(locations, self)
|
|
69 |
res = gen_cfile.GenerateFile(filepath, master)
|
|
70 |
if not res:
|
12
|
71 |
s = str(self.BaseParams.BusId)+"_IN(){}\n"
|
|
72 |
s += "CanOpen(str(\""+self.CanFestivalNode.CAN_Device)+"\")"
|
11
|
73 |
f = file(filepath, 'a')
|
|
74 |
f.write(s)
|
|
75 |
else:
|
|
76 |
pass # error
|
|
77 |
|