author | Edouard Tisserant |
Wed, 16 Nov 2011 17:47:13 +0100 | |
changeset 635 | fcdb60cacb2c |
parent 630 | 91b2ae63ea3d |
child 651 | cbeb769b0a56 |
permissions | -rw-r--r-- |
31 | 1 |
import wx |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
2 |
import os |
401
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
3 |
from xml.dom import minidom |
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
4 |
import cPickle |
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
5 |
|
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
6 |
from xmlclass import * |
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
7 |
|
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
610
diff
changeset
|
8 |
from plugger import PlugTemplate, opjimg |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
9 |
from CFileEditor import CFileEditor |
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
610
diff
changeset
|
10 |
from PLCControler import PLCControler, UndoBuffer, LOCATION_PLUGIN, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
610
diff
changeset
|
11 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
610
diff
changeset
|
12 |
CFileClasses = GenerateClassesFromXSD(os.path.join(os.path.dirname(__file__), "cext_xsd.xsd")) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
13 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
14 |
TYPECONVERSION = {"BOOL" : "X", "SINT" : "B", "INT" : "W", "DINT" : "D", "LINT" : "L", |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
15 |
"USINT" : "B", "UINT" : "W", "UDINT" : "D", "ULINT" : "L", "REAL" : "D", "LREAL" : "L", |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
16 |
"STRING" : "B", "BYTE" : "B", "WORD" : "W", "DWORD" : "D", "LWORD" : "L", "WSTRING" : "W"} |
31 | 17 |
|
18 |
class _Cfile: |
|
19 |
XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
|
20 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
|
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
21 |
<xsd:element name="CExtension"> |
31 | 22 |
<xsd:complexType> |
45 | 23 |
<xsd:attribute name="CFLAGS" type="xsd:string" use="required"/> |
24 |
<xsd:attribute name="LDFLAGS" type="xsd:string" use="required"/> |
|
31 | 25 |
</xsd:complexType> |
26 |
</xsd:element> |
|
27 |
</xsd:schema> |
|
28 |
""" |
|
29 |
def __init__(self): |
|
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
30 |
filepath = self.CFileName() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
31 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
32 |
self.Buffering = False |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
33 |
self.CFile = CFileClasses["CFile"]() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
34 |
self.CFileBuffer = UndoBuffer(self.Copy(self.CFile), False) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
35 |
if os.path.isfile(filepath): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
36 |
xmlfile = open(filepath, 'r') |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
37 |
tree = minidom.parse(xmlfile) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
38 |
xmlfile.close() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
39 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
40 |
for child in tree.childNodes: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
41 |
if child.nodeType == tree.ELEMENT_NODE and child.nodeName == "CFile": |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
42 |
self.CFile.loadXMLTree(child, ["xmlns", "xmlns:xsi", "xsi:schemaLocation"]) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
43 |
self.CFileBuffer = UndoBuffer(self.Copy(self.CFile), True) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
44 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
45 |
self.OnPlugSave() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
46 |
|
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
610
diff
changeset
|
47 |
def GetIconPath(self, name): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
610
diff
changeset
|
48 |
return opjimg(name) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
610
diff
changeset
|
49 |
|
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
50 |
def CFileName(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
51 |
return os.path.join(self.PlugPath(), "cfile.xml") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
52 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
53 |
def GetFilename(self): |
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
610
diff
changeset
|
54 |
return self.MandatoryParams[1].getName() |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
55 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
56 |
def GetBaseTypes(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
57 |
return self.GetPlugRoot().GetBaseTypes() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
58 |
|
610
00df5b1db283
Disabling definition of enumerated and structure variables for interfacing with PLC in c_ext plug-in
laurent
parents:
603
diff
changeset
|
59 |
def GetDataTypes(self, basetypes = False, only_locatables = False): |
00df5b1db283
Disabling definition of enumerated and structure variables for interfacing with PLC in c_ext plug-in
laurent
parents:
603
diff
changeset
|
60 |
return self.GetPlugRoot().GetDataTypes(basetypes=basetypes, only_locatables=only_locatables) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
61 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
62 |
def GetSizeOfType(self, type): |
610
00df5b1db283
Disabling definition of enumerated and structure variables for interfacing with PLC in c_ext plug-in
laurent
parents:
603
diff
changeset
|
63 |
return TYPECONVERSION.get(self.GetPlugRoot().GetBaseType(type), None) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
64 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
65 |
def SetVariables(self, variables): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
66 |
self.CFile.variables.setvariable([]) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
67 |
for var in variables: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
68 |
variable = CFileClasses["variables_variable"]() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
69 |
variable.setname(var["Name"]) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
70 |
variable.settype(var["Type"]) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
71 |
variable.setclass(var["Class"]) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
72 |
self.CFile.variables.appendvariable(variable) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
73 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
74 |
def GetVariables(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
75 |
datas = [] |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
76 |
for var in self.CFile.variables.getvariable(): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
77 |
datas.append({"Name" : var.getname(), "Type" : var.gettype(), "Class" : var.getclass()}) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
78 |
return datas |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
79 |
|
401
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
80 |
def GetVariableLocationTree(self): |
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
81 |
'''See PlugTemplate.GetVariableLocationTree() for a description.''' |
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
82 |
|
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
83 |
current_location = ".".join(map(str, self.GetCurrentLocation())) |
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
84 |
|
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
85 |
vars = [] |
603
e1ef99c609eb
added memory location support to C file pluguin
Edouard Tisserant
parents:
430
diff
changeset
|
86 |
input = memory = output = 0 |
401
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
87 |
for var in self.CFile.variables.getvariable(): |
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
88 |
var_size = self.GetSizeOfType(var.gettype()) |
610
00df5b1db283
Disabling definition of enumerated and structure variables for interfacing with PLC in c_ext plug-in
laurent
parents:
603
diff
changeset
|
89 |
var_location = "" |
401
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
90 |
if var.getclass() == "input": |
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
91 |
var_class = LOCATION_VAR_INPUT |
610
00df5b1db283
Disabling definition of enumerated and structure variables for interfacing with PLC in c_ext plug-in
laurent
parents:
603
diff
changeset
|
92 |
if var_size is not None: |
00df5b1db283
Disabling definition of enumerated and structure variables for interfacing with PLC in c_ext plug-in
laurent
parents:
603
diff
changeset
|
93 |
var_location = "%%I%s%s.%d"%(var_size, current_location, input) |
401
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
94 |
input += 1 |
603
e1ef99c609eb
added memory location support to C file pluguin
Edouard Tisserant
parents:
430
diff
changeset
|
95 |
elif var.getclass() == "memory": |
e1ef99c609eb
added memory location support to C file pluguin
Edouard Tisserant
parents:
430
diff
changeset
|
96 |
var_class = LOCATION_VAR_INPUT |
610
00df5b1db283
Disabling definition of enumerated and structure variables for interfacing with PLC in c_ext plug-in
laurent
parents:
603
diff
changeset
|
97 |
if var_size is not None: |
00df5b1db283
Disabling definition of enumerated and structure variables for interfacing with PLC in c_ext plug-in
laurent
parents:
603
diff
changeset
|
98 |
var_location = "%%M%s%s.%d"%(var_size, current_location, memory) |
603
e1ef99c609eb
added memory location support to C file pluguin
Edouard Tisserant
parents:
430
diff
changeset
|
99 |
memory += 1 |
401
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
100 |
else: |
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
101 |
var_class = LOCATION_VAR_OUTPUT |
610
00df5b1db283
Disabling definition of enumerated and structure variables for interfacing with PLC in c_ext plug-in
laurent
parents:
603
diff
changeset
|
102 |
if var_size is not None: |
00df5b1db283
Disabling definition of enumerated and structure variables for interfacing with PLC in c_ext plug-in
laurent
parents:
603
diff
changeset
|
103 |
var_location = "%%Q%s%s.%d"%(var_size, current_location, output) |
401
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
104 |
output += 1 |
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
105 |
vars.append({"name": var.getname(), |
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
106 |
"type": var_class, |
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
107 |
"size": var_size, |
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
108 |
"IEC_type": var.gettype(), |
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
109 |
"location": var_location, |
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
110 |
"description": "", |
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
111 |
"children": []}) |
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
112 |
|
402
984e238e63d0
Bugs on displaying plugin available variables in PluginTree fixed
laurent
parents:
401
diff
changeset
|
113 |
return {"name": self.BaseParams.getName(), |
984e238e63d0
Bugs on displaying plugin available variables in PluginTree fixed
laurent
parents:
401
diff
changeset
|
114 |
"type": LOCATION_PLUGIN, |
984e238e63d0
Bugs on displaying plugin available variables in PluginTree fixed
laurent
parents:
401
diff
changeset
|
115 |
"location": self.GetFullIEC_Channel(), |
984e238e63d0
Bugs on displaying plugin available variables in PluginTree fixed
laurent
parents:
401
diff
changeset
|
116 |
"children": vars} |
401
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
117 |
|
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
118 |
def SetPartText(self, name, text): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
119 |
if name == "Includes": |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
120 |
self.CFile.includes.settext(text) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
121 |
elif name == "Globals": |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
122 |
self.CFile.globals.settext(text) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
123 |
elif name == "Init": |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
124 |
self.CFile.initFunction.settext(text) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
125 |
elif name == "CleanUp": |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
126 |
self.CFile.cleanUpFunction.settext(text) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
127 |
elif name == "Retrieve": |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
128 |
self.CFile.retrieveFunction.settext(text) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
129 |
elif name == "Publish": |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
130 |
self.CFile.publishFunction.settext(text) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
131 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
132 |
def GetPartText(self, name): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
133 |
if name == "Includes": |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
134 |
return self.CFile.includes.gettext() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
135 |
elif name == "Globals": |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
136 |
return self.CFile.globals.gettext() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
137 |
elif name == "Init": |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
138 |
return self.CFile.initFunction.gettext() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
139 |
elif name == "CleanUp": |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
140 |
return self.CFile.cleanUpFunction.gettext() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
141 |
elif name == "Retrieve": |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
142 |
return self.CFile.retrieveFunction.gettext() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
143 |
elif name == "Publish": |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
144 |
return self.CFile.publishFunction.gettext() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
145 |
return "" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
146 |
|
203 | 147 |
def _OpenView(self): |
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
610
diff
changeset
|
148 |
app_frame = self.GetPlugRoot().AppFrame |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
610
diff
changeset
|
149 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
610
diff
changeset
|
150 |
cfileeditor = CFileEditor(app_frame.TabsOpened, self, app_frame) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
610
diff
changeset
|
151 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
610
diff
changeset
|
152 |
app_frame.EditProjectElement(cfileeditor, self.GetFilename()) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
610
diff
changeset
|
153 |
|
65 | 154 |
PluginMethods = [ |
199 | 155 |
{"bitmap" : os.path.join("images", "EditCfile"), |
361 | 156 |
"name" : _("Edit C File"), |
157 |
"tooltip" : _("Edit C File"), |
|
105
434aed8dc58d
Added ability to override plugin methods with arbitrary python code (methods.py) when loading plugins
etisserant
parents:
86
diff
changeset
|
158 |
"method" : "_OpenView"}, |
65 | 159 |
] |
45 | 160 |
|
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
610
diff
changeset
|
161 |
def PlugTestModified(self): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
610
diff
changeset
|
162 |
return self.ChangesToSave or not self.CFileIsSaved() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
610
diff
changeset
|
163 |
|
31 | 164 |
def OnPlugSave(self): |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
165 |
filepath = self.CFileName() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
166 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
167 |
text = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
168 |
extras = {"xmlns":"http://www.w3.org/2001/XMLSchema", |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
169 |
"xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance", |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
170 |
"xsi:schemaLocation" : "cext_xsd.xsd"} |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
171 |
text += self.CFile.generateXMLText("CFile", 0, extras) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
172 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
173 |
xmlfile = open(filepath,"w") |
430 | 174 |
xmlfile.write(text.encode("utf-8")) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
175 |
xmlfile.close() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
176 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
177 |
self.CFileBuffer.CurrentSaved() |
31 | 178 |
return True |
179 |
||
203 | 180 |
def PlugGenerate_C(self, buildpath, locations): |
31 | 181 |
""" |
182 |
Generate C code |
|
183 |
@param current_location: Tupple containing plugin IEC location : %I0.0.4.5 => (0,0,4,5) |
|
184 |
@param locations: List of complete variables locations \ |
|
185 |
[{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...) |
|
186 |
"NAME" : name of the variable (generally "__IW0_1_2" style) |
|
187 |
"DIR" : direction "Q","I" or "M" |
|
188 |
"SIZE" : size "X", "B", "W", "D", "L" |
|
189 |
"LOC" : tuple of interger for IEC location (0,1,2,...) |
|
190 |
}, ...] |
|
191 |
@return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
|
192 |
""" |
|
193 |
current_location = self.GetCurrentLocation() |
|
194 |
# define a unique name for the generated C file |
|
401
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
195 |
location_str = "_".join(map(str, current_location)) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
196 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
197 |
text = "/* Code generated by Beremiz c_ext plugin */\n\n" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
198 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
199 |
# Adding includes |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
200 |
text += "/* User includes */\n" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
201 |
text += self.CFile.includes.gettext() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
202 |
text += "\n" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
203 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
204 |
text += """/* Beremiz c_ext plugin includes */ |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
205 |
#ifdef _WINDOWS_H |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
206 |
#include "iec_types.h" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
207 |
#else |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
208 |
#include "iec_std_lib.h" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
209 |
#endif |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
210 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
211 |
""" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
212 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
213 |
# Adding variables |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
214 |
vars = [] |
603
e1ef99c609eb
added memory location support to C file pluguin
Edouard Tisserant
parents:
430
diff
changeset
|
215 |
inputs = memories = outputs = 0 |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
216 |
for variable in self.CFile.variables.variable: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
217 |
var = {"Name" : variable.getname(), "Type" : variable.gettype()} |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
218 |
if variable.getclass() == "input": |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
219 |
var["location"] = "__I%s%s_%d"%(self.GetSizeOfType(var["Type"]), location_str, inputs) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
220 |
inputs += 1 |
603
e1ef99c609eb
added memory location support to C file pluguin
Edouard Tisserant
parents:
430
diff
changeset
|
221 |
elif variable.getclass() == "memory": |
e1ef99c609eb
added memory location support to C file pluguin
Edouard Tisserant
parents:
430
diff
changeset
|
222 |
var["location"] = "__M%s%s_%d"%(self.GetSizeOfType(var["Type"]), location_str, memories) |
e1ef99c609eb
added memory location support to C file pluguin
Edouard Tisserant
parents:
430
diff
changeset
|
223 |
memories += 1 |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
224 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
225 |
var["location"] = "__Q%s%s_%d"%(self.GetSizeOfType(var["Type"]), location_str, outputs) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
226 |
outputs += 1 |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
227 |
vars.append(var) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
228 |
text += "/* Beremiz c_ext plugin user variables definition */\n" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
229 |
base_types = self.GetPlugRoot().GetBaseTypes() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
230 |
for var in vars: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
231 |
if var["Type"] in base_types: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
232 |
prefix = "IEC_" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
233 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
234 |
prefix = "" |
180
f7dc9acda79e
Various fixes in c_ext, now, located vars are pointed.
etisserant
parents:
146
diff
changeset
|
235 |
text += "%s%s beremiz%s;\n"%(prefix, var["Type"], var["location"]) |
f7dc9acda79e
Various fixes in c_ext, now, located vars are pointed.
etisserant
parents:
146
diff
changeset
|
236 |
text += "%s%s *%s = &beremiz%s;\n"%(prefix, var["Type"], var["location"], var["location"]) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
237 |
text += "/* User variables reference */\n" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
238 |
for var in vars: |
180
f7dc9acda79e
Various fixes in c_ext, now, located vars are pointed.
etisserant
parents:
146
diff
changeset
|
239 |
text += "#define %s beremiz%s\n"%(var["Name"], var["location"]) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
240 |
text += "\n" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
241 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
242 |
# Adding user global variables and routines |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
243 |
text += "/* User internal user variables and routines */\n" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
244 |
text += self.CFile.globals.gettext() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
245 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
246 |
# Adding Beremiz plugin functions |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
247 |
text += "/* Beremiz plugin functions */\n" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
248 |
text += "int __init_%s(int argc,char **argv)\n{\n"%location_str |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
249 |
text += self.CFile.initFunction.gettext() |
180
f7dc9acda79e
Various fixes in c_ext, now, located vars are pointed.
etisserant
parents:
146
diff
changeset
|
250 |
text += " return 0;\n" |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
251 |
text += "\n}\n\n" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
252 |
|
419 | 253 |
text += "void __cleanup_%s(void)\n{\n"%location_str |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
254 |
text += self.CFile.cleanUpFunction.gettext() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
255 |
text += "\n}\n\n" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
256 |
|
419 | 257 |
text += "void __retrieve_%s(void)\n{\n"%location_str |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
258 |
text += self.CFile.retrieveFunction.gettext() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
259 |
text += "\n}\n\n" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
260 |
|
419 | 261 |
text += "void __publish_%s(void)\n{\n"%location_str |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
262 |
text += self.CFile.publishFunction.gettext() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
263 |
text += "\n}\n\n" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
264 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
265 |
Gen_Cfile_path = os.path.join(buildpath, "CFile_%s.c"%location_str) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
266 |
cfile = open(Gen_Cfile_path,'w') |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
267 |
cfile.write(text) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
268 |
cfile.close() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
269 |
|
418 | 270 |
matiec_flags = '"-I%s"'%os.path.abspath(self.GetPlugRoot().GetIECLibPath()) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
271 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
272 |
return [(Gen_Cfile_path, str(self.CExtension.getCFLAGS() + matiec_flags))],str(self.CExtension.getLDFLAGS()),True |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
273 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
274 |
#------------------------------------------------------------------------------- |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
275 |
# Current Buffering Management Functions |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
276 |
#------------------------------------------------------------------------------- |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
277 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
278 |
""" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
279 |
Return a copy of the project |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
280 |
""" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
281 |
def Copy(self, model): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
282 |
return cPickle.loads(cPickle.dumps(model)) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
283 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
284 |
def BufferCFile(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
285 |
self.CFileBuffer.Buffering(self.Copy(self.CFile)) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
286 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
287 |
def StartBuffering(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
288 |
self.CFileBuffer.Buffering(self.CFile) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
289 |
self.Buffering = True |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
290 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
291 |
def EndBuffering(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
292 |
if self.Buffering: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
293 |
self.CFile = self.Copy(self.CFile) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
294 |
self.Buffering = False |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
295 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
296 |
def CFileIsSaved(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
297 |
if self.CFileBuffer: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
298 |
return self.CFileBuffer.IsCurrentSaved() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
299 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
300 |
return True |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
301 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
302 |
def LoadPrevious(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
303 |
self.CFile = self.Copy(self.CFileBuffer.Previous()) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
304 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
305 |
def LoadNext(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
306 |
self.CFile = self.Copy(self.CFileBuffer.Next()) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
307 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
308 |
def GetBufferState(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
309 |
first = self.CFileBuffer.IsFirst() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
310 |
last = self.CFileBuffer.IsLast() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
311 |
return not first, not last |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
312 |
|
31 | 313 |
class RootClass: |
314 |
||
106
9810689febb0
Added plugins creation helpstrings, changed GUI layout (more compact), solved staticbitmap issues on win32, re-designed some icons...
etisserant
parents:
105
diff
changeset
|
315 |
PlugChildsTypes = [("C_File",_Cfile, "C file")] |
31 | 316 |
|
203 | 317 |
def PlugGenerate_C(self, buildpath, locations): |
55
9c26e67c041a
Updated plugins PluGenerate_C to conform to plugger.py
etisserant
parents:
49
diff
changeset
|
318 |
return [],"",False |
31 | 319 |
|
320 |