Exemplo n.º 1
0
def GetAppRevision():
    rev = None
    app_dir = paths.AbsDir(__file__)
    try:
        pipe = subprocess.Popen(["git", "pull"],
                                stdout=subprocess.PIPE,
                                cwd=app_dir,
                                shell=True)
        pipe = subprocess.Popen(["git", "rev-parse", "--abbrev-ref", "HEAD"],
                                stdout=subprocess.PIPE,
                                cwd=app_dir,
                                shell=True)
        rev = pipe.communicate()
        rev = rev[0]
        rev = rev.decode()
        if pipe.returncode != 0:
            rev = None
    except Exception:
        pass

    # if this is not mercurial repository
    # try to read revision from file
    if rev is None:
        try:
            f = open(os.path.join(app_dir, "revision"))
            rev = f.readline()
        except Exception:
            pass
    return rev
Exemplo n.º 2
0
def GetAboutDialogInfo():
    import wx
    info = wx.AboutDialogInfo()

    info.Name = "PLCOpenEditorLight"
    info.Version = app_version

    info.Copyright = ""
    info.Copyright += "(C) 2016-2017 Andrey Skvortsov\n"
    info.Copyright += "(C) 2008-2015 Eduard Tisserant\n"
    info.Copyright += "(C) 2008-2015 Laurent Bessard"

    info.WebSite = ("http://beremiz.org", "beremiz.org")

    info.Description = _("Open Source framework for automation, "
                         "implemented IEC 61131 IDE with constantly growing set of extensions "
                         "and flexible PLC runtime.")

    info.Developers = (
        "Andrey Skvortsov <*****@*****.**>",
        "Sergey Surkov <*****@*****.**>",
        "Edouard Tisserant <*****@*****.**>",
        "Laurent Bessard <*****@*****.**>")

    info.License = (
        '\n This program is free software; you can redistribute it and/or\n'
        ' modify it under the terms of the GNU General Public License\n'
        ' as published by the Free Software Foundation; either version 2\n'
        ' of the License, or (at your option) any later version.\n'
        '\n'
        ' This program is distributed in the hope that it will be useful,\n'
        ' but WITHOUT ANY WARRANTY; without even the implied warranty of\n'
        ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n'
        ' GNU General Public License below for more details.\n'
        '\n'
    )

    # read license file
    path = paths.AbsDir(__file__)
    license_path = os.path.join(path, "COPYING")
    if os.path.exists(license_path):
        with open(license_path) as f:
            info.License += f.read()

    info.Icon = wx.Icon(os.path.join(path, "images", "about_brz_logo.png"), wx.BITMAP_TYPE_PNG)

    info.Translators = (
        "This version does not support multilingual",
        "notation, currently available English only.",
        "",
    )
    
    info.Artists = (
        "Extracting editor code, interface rearrange", 
        "with some fixings relative to simplification", 
        "was been done by Simplest System Solutions",
        "http://sites.google.com/view/simplest/ ",
        "",
    )
    return info
Exemplo n.º 3
0
 def platformio_ini(self,
                    platform,
                    framework,
                    board,
                    build_flags,
                    package_prog,
                    package_test,
                    upload_protocol=None,
                    options=[]):
     env = Environment(loader=FileSystemLoader(
         searchpath=paths.AbsDir(__file__)))
     ps = env.get_template("platformio.ini")
     txt = ps.render(platform=platform,
                     framework=framework,
                     model=board,
                     lib_path=os.path.join(self.app_path, 'lib'),
                     core_dir=os.path.join(self.app_path, '.platformio'),
                     library_dir=os.path.join(self.app_path, 'library'),
                     build_flags=build_flags,
                     package_prog=package_prog,
                     package_test=package_test,
                     upload_protocol=upload_protocol,
                     options=options)
     overwrite = True
     if exists('platformio.ini'):
         with open('platformio.ini', 'r') as output:
             t = output.read()
             if t == txt:
                 overwrite = False
     if overwrite:
         with open('platformio.ini', 'w') as output:
             output.write(txt)
         self.CTRInstance.logger.write(_("reBuild config File.\n"))
     else:
         self.CTRInstance.logger.write(_("config File no change.\n"))
Exemplo n.º 4
0
 def __init__(self):
     self.updateinfo_url = None
     self.extensions = []
     self.app_dir = paths.AbsDir(__file__)
     self.projectOpen = None
     self.buildpath = None
     self.splash = None
     self.splashPath = self.Bpath("images", "splash.png")
Exemplo n.º 5
0
def GetAboutDialogInfo():
    import wx
    info = wx.AboutDialogInfo()

    info.Name = "Beremiz"
    info.Version = app_version

    info.Copyright = ""
    info.Copyright += "(C) 2016-2017 Andrey Skvortsov\n"
    info.Copyright += "(C) 2008-2015 Eduard Tisserant\n"
    info.Copyright += "(C) 2008-2015 Laurent Bessard"

    info.WebSite = ("http://beremiz.org", "beremiz.org")

    info.Description = _(
        "Open Source framework for automation, "
        "implemented IEC 61131 IDE with constantly growing set of extensions "
        "and flexible PLC runtime.")

    info.Developers = ("Andrey Skvortsov <*****@*****.**>",
                       "Sergey Surkov <*****@*****.**>",
                       "Edouard Tisserant <*****@*****.**>",
                       "Laurent Bessard <*****@*****.**>")

    info.License = (
        '\n This program is free software; you can redistribute it and/or\n'
        ' modify it under the terms of the GNU General Public License\n'
        ' as published by the Free Software Foundation; either version 2\n'
        ' of the License, or (at your option) any later version.\n'
        '\n'
        ' This program is distributed in the hope that it will be useful,\n'
        ' but WITHOUT ANY WARRANTY; without even the implied warranty of\n'
        ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n'
        ' GNU General Public License below for more details.\n'
        '\n'
        '\n'
        '\n'
        '')

    # read license file
    path = paths.AbsDir(__file__)
    license_path = os.path.join(path, "COPYING")
    license = ''
    if os.path.exists(license_path):
        with open(license_path) as f:
            info.License += f.read()

    info.Icon = wx.Icon(os.path.join(path, "images", "about_brz_logo.png"),
                        wx.BITMAP_TYPE_PNG)

    info.Translators = (
        "Russian\t- Andrey Skvortsov <*****@*****.**>",
        "Korean\t- Reinhard Lee <*****@*****.**>",
        "German\t- Mark Muzenhardt <*****@*****.**>",
        "French\t- Laurent Bessard <*****@*****.**>",
        "      \t  Fabien M <*****@*****.**>", "Slovenian\t- Janez Pregelj",
        "Portuguese\t- Thiago Alves <*****@*****.**>")
    return info
Exemplo n.º 6
0
    def CTNGenerate_C(self, buildpath, locations):
        """
        Return C code generated by iec2c compiler 
        when _generate_softPLC have been called
        @param locations: ignored
        @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
        """
        
        current_location = self.GetCurrentLocation()
        # define a unique name for the generated C file
        location_str = "_".join(map(lambda x:str(x), current_location))
        
        res = ([], "", False)
        
        svgfile=self._getSVGpath()
        if os.path.exists(svgfile):
            res += (("gui.svg", file(svgfile,"rb")),)

        svguiserverfile = open(self._getSVGUIserverpath(), 'r')
        svguiservercode = svguiserverfile.read()
        svguiserverfile.close()

        svguilibpath = os.path.join(self._getBuildPath(), "svguilib.js")
        svguilibfile = open(svguilibpath, 'w')
        fpath=paths.AbsDir(__file__)
        svguilibfile.write(translate(os.path.join(fpath, "pyjs", "lib", "sys.py"), "sys"))
        svguilibfile.write(open(os.path.join(fpath, "pyjs", "lib", "_pyjs.js"), 'r').read())
        svguilibfile.write(translate(os.path.join(fpath, "pyjs", "lib", "pyjslib.py"), "pyjslib"))
        svguilibfile.write(translate(os.path.join(fpath, "svguilib.py"), "svguilib"))
        svguilibfile.write("pyjslib();\nsvguilib();\n")
        svguilibfile.write(open(os.path.join(fpath, "pyjs", "lib", "json.js"), 'r').read())
        svguilibfile.write(open(os.path.join(fpath, "livesvg.js"), 'r').read())
        svguilibfile.close()
        jsmodules = {"LiveSVGPage": "svguilib.js"}
        res += (("svguilib.js", file(svguilibpath,"rb")),)
        
        runtimefile_path = os.path.join(buildpath, "runtime_%s.py"%location_str)
        runtimefile = open(runtimefile_path, 'w')
        runtimefile.write(svguiservercode % {"svgfile" : "gui.svg"})
        runtimefile.write("""
def _runtime_%(location)s_start():
    website.LoadHMI(%(svgui_class)s, %(jsmodules)s)
    
def _runtime_%(location)s_stop():
    website.UnLoadHMI()
    
""" % {"location": location_str,
       "svgui_class": "SVGUI_HMI",
       "jsmodules" : str(jsmodules),
      })
        runtimefile.close()
        
        res += (("runtime_%s.py"%location_str, file(runtimefile_path,"rb")),)
        
        return res
Exemplo n.º 7
0
 def __init__(self):
     self.app = None
     self.frame = None
     self.updateinfo_url = None
     self.extensions = []
     self.app_dir = paths.AbsDir(__file__)
     self.projectOpen = None
     self.buildpath = None
     self.splash = None
     self.splashPath = self.Bpath("images", "splash.png")
     self.modules = ["BeremizIDE"]
     self.debug = os.path.exists("BEREMIZ_DEBUG")
     self.handle_exception = None
Exemplo n.º 8
0
 def __init__(self):
     self.app = None
     self.frame = None
     self.updateinfo_url = None
     self.extensions = []
     self.app_dir = paths.AbsDir(__file__)
     if hasattr(sys, 'frozen'):
         self.app_dir = os.path.join(self.app_dir, '..')
     self.projectOpen = None
     self.buildpath = None
     self.splash = None
     self.splashPath = self.Bpath("images", oem.logo)
     self.modules = ["BeremizIDE"]
     self.debug = os.path.exists("BEREMIZ_DEBUG")
     self.handle_exception = None
     self.test = False
Exemplo n.º 9
0
def GetAppRevision():
    rev = None
    app_dir = paths.AbsDir(__file__)
    try:
        pipe = subprocess.Popen(["hg", "id", "-i"],
                                stdout=subprocess.PIPE,
                                cwd=app_dir)
        rev = pipe.communicate()[0]
        if pipe.returncode != 0:
            rev = None
    except Exception:
        pass

    # if this is not mercurial repository
    # try to read revision from file
    if rev is None:
        try:
            f = open(os.path.join(app_dir, "revision"))
            rev = f.readline()
        except Exception:
            pass
    return rev
Exemplo n.º 10
0
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.


from os.path import join

from util import paths
from util.TranslationCatalogs import NoTranslate

sd = paths.AbsDir(__file__)

# Override gettext _ in this module
# since we just want string to be added to dictionnary
# but translation should happen here
_ = NoTranslate

LANGUAGES = ["IL", "ST", "FBD", "LD", "SFC"]

LOCATIONDATATYPES = {"X": ["BOOL"],
                     "B": ["SINT", "USINT", "BYTE", "STRING"],
                     "W": ["INT", "UINT", "WORD", "WSTRING"],
                     "D": ["DINT", "UDINT", "REAL", "DWORD"],
                     "L": ["LINT", "ULINT", "LREAL", "LWORD"]}

# -------------------------------------------------------------------------------
Exemplo n.º 11
0
 def ConfNodePath(self):
     return paths.AbsDir(__file__)
Exemplo n.º 12
0
def GetAboutDialogInfo():
    import wx
    info = wx.adv.AboutDialogInfo()

    info.Name = "NetPac"
    info.Version = app_version

    info.Copyright = ""
    # info.Copyright += "(C) 2016-2018 Andrey Skvortsov\n"
    # info.Copyright += "(C) 2008-2018 Eduard Tisserant\n"
    # info.Copyright += "(C) 2008-2015 Laurent Bessard"

    info.WebSite = ''  # '("http://beremiz.org", "beremiz.org")

    info.Description = _(
        "Open Source framework for automation, "
        "implemented IEC 61131 IDE with constantly growing set of extensions "
        "and flexible PLC runtime.")

    info.Developers = (
        # "Andrey Skvortsov <*****@*****.**>",
        # "Sergey Surkov <*****@*****.**>",
        # "Edouard Tisserant <*****@*****.**>",
        # "Laurent Bessard <*****@*****.**>"
    )

    info.License = (
        # '\n This program is free software; you can redistribute it and/or\n'
        # ' modify it under the terms of the GNU General Public License\n'
        # ' as published by the Free Software Foundation; either version 2\n'
        # ' of the License, or (at your option) any later version.\n'
        # '\n'
        # ' This program is distributed in the hope that it will be useful,\n'
        # ' but WITHOUT ANY WARRANTY; without even the implied warranty of\n'
        # ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n'
        # ' GNU General Public License below for more details.\n'
        '\n'
        '\n'
        '\n'
        '')

    # read license file
    path = paths.AbsDir(__file__)
    license_path = os.path.join(path, "COPYING")
    # if os.path.exists(license_path):
    #     with open(license_path) as f:
    #         info.License += f.read()

    info.Icon = wx.Icon(os.path.join(path, "images", "about_brz_logo.png"),
                        wx.BITMAP_TYPE_PNG)

    info.Translators = (
        "Basque",
        "José Miguel Andonegi <*****@*****.**>, 2019",
        "",
        "Bengali (Bangladesh)",
        "  Adhir Dutta <*****@*****.**>, 2017",
        "",
        "Chinese",
        "  Frank Guan <*****@*****.**>, 2018",
        "  Tango Wu <*****@*****.**>, 2017",
        "  Yiwei Yan <*****@*****.**>, 2018",
        "  Ji Wang <*****@*****.**>, 2019",
        "  珂 曾 <*****@*****.**>, 2019",
        "  Gastonfeng<*****@*****.**>, 2019",
        "",
        "Dutch (Netherlands)",
        "  Martijn Berntsen <*****@*****.**>, 2019",
        "  Jordy van der Heijden <*****@*****.**>, 2018",
        "",
        "French",
        "  Edouard Tisserant <*****@*****.**>, 2018",
        "  Fabien Marteau <*****@*****.**>, 2017",
        "  Laurent Bessard <*****@*****.**>, 2008",
        "",
        "German",
        "  Andrey Skvortsov <*****@*****.**>, 2017",
        "  Hendrik Knackstedt <*****@*****.**>, 2017 ",
        "  Mark Muzenhardt <*****@*****.**>, 2012",
        "",
        "Hungarian",
        "  Krisztián Veress <*****@*****.**>, 2018",
        "  Gábor Véninger <*****@*****.**>, 2017",
        "",
        "Italian",
        "  Luca Magnabosco <*****@*****.**>, 2017",
        "  Manuele Conti <*****@*****.**>, 2017",
        "",
        "Korean",
        "  Ikhwan Kim <*****@*****.**>, 2018",
        "  Reinhard Lee <*****@*****.**>, 2012",
        "",
        "Polish",
        "  Adam B <*****@*****.**>, 2019",
        "",
        "Portuguese",
        "  Pedro Coimbra <*****@*****.**>, 2017",
        "",
        "Portuguese (Brazil)",
        "  Rodrigo Rolle <*****@*****.**>, 2018",
        "  Thiago Alves <*****@*****.**>, 2017",
        "",
        "Romanian",
        "  Emil Saracutu <*****@*****.**>, 2018",
        "",
        "Russian",
        "  Andrey Skvortsov <*****@*****.**>, 2018",
        "  Sergey Surkov <*****@*****.**>, 2018",
        "  zx_alexis <*****@*****.**>, 2017",
        "",
        "Slovenian",
        "  Janez Pregelj <*****@*****.**>, 2018",
        "  Andraz Gregorcic <*****@*****.**>, 2017",
        "",
        "Spanish",
        "  Carlos Guilarte <*****@*****.**>, 2018",
        "  Yegor Yefremov <*****@*****.**>, 2018",
        "  Jorge Rojas, 2018",
        "  Marcial González de Armas <*****@*****.**>, 2017",
        "  Nelson Mambre <*****@*****.**>, 2017",
        "",
        "Turkish",
        "  Ibrahim Kilicarslan <*****@*****.**>, 2018",
        "",
        "Vietnamese (Viet Nam)",
        "  Nhất Thìn, 2019",
        "",
    )
    return info
Exemplo n.º 13
0
                for blocktype in category["list"]:
                    tempList.append(blocktype["name"])
                LibContents.append(tempList)
        return (LibNameList, LibContents)

    def secondHello(self):
        print("I am python hello")
        return []

if __name__ == '__main__':
    #    print type(__file__)
    #    print AbsNeighbourFile(__file__,"plc.xml")
    controller = ProjectControllerPy()
    print("===================== get Library contents =======================")
    print controller.getLibraryNodes()
    ProjectDir = paths.AbsDir(__file__)
    print ProjectDir
    #    print ProjectDir
    #    filePath = os.path.join(ProjectDir,"plc.xml")
    #    print filePath

    controller.LoadProject(ProjectDir)
    #    controller.NewProject(ProjectDir)

    #    print controller.getProjectCurrentConfigName()
    print("==================== getBlockResource ====================")
    print controller.getBlockResource()
    print("===================== getResoueceVariables ================")
    print controller.getEditedResourceVariables("R::config::res1")
    #    print controller.getEditedResourceInfos("R::config::resource0")
    print("======================= first time ========================")
Exemplo n.º 14
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This file is part of Beremiz.
# See COPYING file for copyrights details.

from __future__ import absolute_import
import os
from lxml import etree
import util.paths as paths
from plcopen.structures import StdBlckLibs

ScriptDirectory = paths.AbsDir(__file__)


class XSLTModelQuery(object):
    """ a class to handle XSLT queries on project and libs """
    def __init__(self, controller, xsltpath, ext=None):
        # arbitrary set debug to false, updated later
        self.debug = False

        # merge xslt extensions for library access to query specific ones
        xsltext = [("GetProject",
                    lambda *_ignored: [controller.GetProject(self.debug)]),
                   ("GetStdLibs",
                    lambda *_ignored: [lib for lib in StdBlckLibs.values()]),
                   ("GetExtensions", lambda *_ignored:
                    [ctn["types"] for ctn in controller.ConfNodeTypes])]

        if ext is not None:
            xsltext.extend(ext)
Exemplo n.º 15
0
def GetAboutDialogInfo():
    import wx
    info = wx.AboutDialogInfo()

    info.Name = "Beremiz"
    info.Version = app_version

    info.Copyright = ""
    info.Copyright += "(C) 2016-2017 Andrey Skvortsov\n"
    info.Copyright += "(C) 2008-2015 Eduard Tisserant\n"
    info.Copyright += "(C) 2008-2015 Laurent Bessard"

    info.WebSite = ("http://beremiz.org", "beremiz.org")

    info.Description = _(
        "Open Source framework for automation, "
        "implemented IEC 61131 IDE with constantly growing set of extensions "
        "and flexible PLC runtime.")

    info.Developers = ("Andrey Skvortsov <*****@*****.**>",
                       "Sergey Surkov <*****@*****.**>",
                       "Edouard Tisserant <*****@*****.**>",
                       "Laurent Bessard <*****@*****.**>")

    info.License = (
        '\n This program is free software; you can redistribute it and/or\n'
        ' modify it under the terms of the GNU General Public License\n'
        ' as published by the Free Software Foundation; either version 2\n'
        ' of the License, or (at your option) any later version.\n'
        '\n'
        ' This program is distributed in the hope that it will be useful,\n'
        ' but WITHOUT ANY WARRANTY; without even the implied warranty of\n'
        ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n'
        ' GNU General Public License below for more details.\n'
        '\n'
        '\n'
        '\n'
        '')

    # read license file
    path = paths.AbsDir(__file__)
    license_path = os.path.join(path, "COPYING")
    if os.path.exists(license_path):
        with open(license_path) as f:
            info.License += f.read()

    info.Icon = wx.Icon(os.path.join(path, "images", "about_brz_logo.png"),
                        wx.BITMAP_TYPE_PNG)

    info.Translators = (
        "Bengali (Bangladesh)",
        "  Adhir Dutta <*****@*****.**>, 2017",
        "",
        "Chinese",
        "  Frank Guan <*****@*****.**>, 2017",
        "",
        "French",
        "  Fabien Marteau <*****@*****.**>, 2017",
        "  Laurent Bessard <*****@*****.**>, 2008",
        "",
        "German",
        "  Andrey Skvortsov <*****@*****.**>, 2017",
        "  Mark Muzenhardt <*****@*****.**>, 2012",
        "",
        "Hungarian",
        "  Gábor Véninger <*****@*****.**>, 2017",
        "",
        "Italian",
        "  Luca Magnabosco <*****@*****.**>, 2017",
        "  Manuele Conti <*****@*****.**>, 2017",
        "",
        "Korean",
        "  Reinhard Lee <*****@*****.**>, 2012",
        "",
        "Portuguese (Portugal)",
        "  Pedro Coimbra <*****@*****.**>, 2017",
        "",
        "Portuguese (Brazil)",
        "  Thiago Alves <*****@*****.**>, 2017",
        "",
        "Russian",
        "  Andrey Skvortsov <*****@*****.**>, 2017",
        "",
        "Slovenian",
        "  Janez Pregelj <*****@*****.**>, 2017",
        "",
        "Spanish",
        "  Marcial González de Armas <*****@*****.**>, 2017",
        "  Carlos Guilarte <*****@*****.**>, 2017",
        "",
    )
    return info
Exemplo n.º 16
0
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

# Package initialisation
"""
Beremiz Targets

- Target are python packages, containing at least one "XSD" file
- Target class may inherit from a toolchain_(toolchainname)
- The target folder's name must match to name define in the XSD for TargetType
"""

from os import listdir, path
import util.paths as paths

_base_path = paths.AbsDir(__file__)


def _GetLocalTargetClassFactory(name):
    return lambda: getattr(__import__(name, globals(), locals()), name +
                           "_target")


targets = dict([(name, {
    "xsd": path.join(_base_path, name, "XSD"),
    "class": _GetLocalTargetClassFactory(name),
    "code": {
        fname: path.join(_base_path, name, fname)
        for fname in listdir(path.join(_base_path, name))
        if (fname.startswith("plc_%s_main" % name) and fname.endswith(".c"))
    }
Exemplo n.º 17
0
    DecodeFileSystemPath
from editors.Viewer import Viewer
from PLCControler import PLCControler
from dialogs import ProjectDialog
from dialogs.AboutDialog import ShowAboutDialog

# -------------------------------------------------------------------------------
#                            PLCOpenEditor Main Class
# -------------------------------------------------------------------------------

# Define PLCOpenEditor FileMenu extra items id
[
    ID_PLCOPENEDITORFILEMENUGENERATE,
] = [wx.NewId() for _init_coll_FileMenu_Items in range(1)]

beremiz_dir = paths.AbsDir(__file__)


class PLCOpenEditor(IDEFrame):

    # Compatibility function for wx versions < 2.6
    if wx.VERSION < (2, 6, 0):

        def Bind(self, event, function, id=None):
            if id is not None:
                event(self, id, function)
            else:
                event(self, function)

    def _init_coll_FileMenu_Items(self, parent):
        AppendMenu(parent,
Exemplo n.º 18
0
from __future__ import absolute_import

from etherlab.etherlab import *
from util.BitmapLibrary import AddBitmapFolder
import util.paths as paths

AddBitmapFolder(os.path.join(paths.AbsDir(__file__), "images"))