PLCControler.py
changeset 2 93bc4c2cf376
parent 0 b622defdfd98
child 4 2de7fd952fdd
equal deleted inserted replaced
1:e9d01d824086 2:93bc4c2cf376
    31 from graphics.GraphicCommons import *
    31 from graphics.GraphicCommons import *
    32 from PLCGenerator import *
    32 from PLCGenerator import *
    33 
    33 
    34 [ITEM_UNEDITABLE, ITEM_PROJECT, ITEM_POU, ITEM_CLASS, ITEM_VARIABLE,
    34 [ITEM_UNEDITABLE, ITEM_PROJECT, ITEM_POU, ITEM_CLASS, ITEM_VARIABLE,
    35  ITEM_TRANSITION, ITEM_ACTION, ITEM_CONFIGURATION, ITEM_RESOURCE] = range(9)
    35  ITEM_TRANSITION, ITEM_ACTION, ITEM_CONFIGURATION, ITEM_RESOURCE] = range(9)
       
    36 
       
    37 """
       
    38 pyxsval is not complete and the parts that are not supported print some error
       
    39 reports. This class is used for not displaying them
       
    40 """
       
    41 class HolePseudoFile:
       
    42     """ Base class for file like objects to facilitate StdOut for the Shell."""
       
    43     def __init__(self, output = None):
       
    44         if output is None: output = []
       
    45         self.output = output
       
    46 
       
    47     def writelines(self, l):
       
    48         map(self.write, l)
       
    49 
       
    50     def write(self, s):
       
    51         pass
       
    52 
       
    53     def flush(self):
       
    54         pass
       
    55     
       
    56     def isatty(self):
       
    57         return false
    36 
    58 
    37 #-------------------------------------------------------------------------------
    59 #-------------------------------------------------------------------------------
    38 #                         Undo Buffer for PLCOpenEditor
    60 #                         Undo Buffer for PLCOpenEditor
    39 #-------------------------------------------------------------------------------
    61 #-------------------------------------------------------------------------------
    40 
    62 
  1753             instances_data.append(new_instance)
  1775             instances_data.append(new_instance)
  1754         return tasks_data, instances_data
  1776         return tasks_data, instances_data
  1755 
  1777 
  1756     def OpenXMLFile(self, filepath):
  1778     def OpenXMLFile(self, filepath):
  1757         if sys:
  1779         if sys:
  1758             sys.stdout = plcopen.HolePseudoFile()
  1780             sys.stdout = HolePseudoFile()
  1759         tree = pyxsval.parseAndValidate(filepath, "plcopen/TC6_XML_V10_B.xsd")
  1781         tree = pyxsval.parseAndValidate(filepath, "plcopen/TC6_XML_V10_B.xsd")
  1760         if sys:
  1782         if sys:
  1761             sys.stdout = sys.__stdout__
  1783             sys.stdout = sys.__stdout__
  1762         
  1784         
  1763         self.Project = plcopen.project()
  1785         self.Project = plcopen.project()
  1779                       "xmlns:xsi" : "http://www.w3.org/2001/XMLSchema-instance",
  1801                       "xmlns:xsi" : "http://www.w3.org/2001/XMLSchema-instance",
  1780                       "xsi:schemaLocation" : "http://www.plcopen.org/xml/tc6.xsd http://www.plcopen.org/xml/tc6.xsd"}
  1802                       "xsi:schemaLocation" : "http://www.plcopen.org/xml/tc6.xsd http://www.plcopen.org/xml/tc6.xsd"}
  1781             text += self.Project.generateXMLText("project", 0, extras)
  1803             text += self.Project.generateXMLText("project", 0, extras)
  1782 
  1804 
  1783             if sys:
  1805             if sys:
  1784                 sys.stdout = plcopen.HolePseudoFile()
  1806                 sys.stdout = HolePseudoFile()
  1785             pyxsval.parseAndValidateString(text, open("plcopen/TC6_XML_V10_B.xsd","r").read())
  1807             pyxsval.parseAndValidateString(text, open("plcopen/TC6_XML_V10_B.xsd","r").read())
  1786             if sys:
  1808             if sys:
  1787                 sys.stdout = sys.__stdout__
  1809                 sys.stdout = sys.__stdout__
  1788             
  1810             
  1789             if filepath:
  1811             if filepath: