andrej@1511: #!/usr/bin/env python andrej@1511: # -*- coding: utf-8 -*- andrej@1511: andrej@1511: # This file is part of Beremiz, a Integrated Development Environment for andrej@1511: # programming IEC 61131-3 automates supporting plcopen standard and CanFestival. andrej@1511: # andrej@1511: # Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD andrej@1511: # andrej@1511: # See COPYING file for copyrights details. andrej@1511: # andrej@1511: # This program is free software; you can redistribute it and/or andrej@1511: # modify it under the terms of the GNU General Public License andrej@1511: # as published by the Free Software Foundation; either version 2 andrej@1511: # of the License, or (at your option) any later version. andrej@1511: # andrej@1511: # This program is distributed in the hope that it will be useful, andrej@1511: # but WITHOUT ANY WARRANTY; without even the implied warranty of andrej@1511: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the andrej@1511: # GNU General Public License for more details. andrej@1511: # andrej@1511: # You should have received a copy of the GNU General Public License andrej@1511: # along with this program; if not, write to the Free Software andrej@1511: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. andrej@1511: Edouard@732: from weakref import ref Edouard@728: Edouard@728: class POULibrary: Edouard@732: def __init__(self, CTR, LibName, TypeStack): Edouard@772: from PLCControler import PLCControler Edouard@732: self.CTR = ref(CTR) Edouard@731: self.LibName = LibName Edouard@728: self.LibraryControler = PLCControler() Edouard@728: self.LibraryControler.OpenXMLFile(self.GetLibraryPath()) Edouard@728: self.LibraryControler.ClearConfNodeTypes() Edouard@728: self.LibraryControler.AddConfNodeTypesList(TypeStack) Edouard@728: self.program = None; Edouard@728: Edouard@728: def GetSTCode(self): Edouard@728: if not self.program: Edouard@728: self.program = self.LibraryControler.GenerateProgram()[0]+"\n" Edouard@728: return self.program Edouard@728: Edouard@731: def GetName(self): Edouard@731: return self.LibName Edouard@732: Edouard@732: def GetCTR(self): Edouard@732: return self.CTR() Edouard@728: Edouard@728: def GetTypes(self): Edouard@728: return {"name" : self.GetName(), "types": self.LibraryControler.Project} Edouard@728: Edouard@728: def GetLibraryPath(self): Edouard@728: raise Exception("Not implemented") Edouard@728: Edouard@728: def Generate_C(self, buildpath, varlist, IECCFLAGS): Edouard@728: # Pure python or IEC libs doesn't produce C code Edouard@728: return ((""), [], False), ""