PLCControler.py
author lbessard
Tue, 10 Jul 2007 09:52:53 +0200
changeset 28 fc23e1f415d8
parent 27 dae55dd9ee14
child 29 3b7e23a323a6
permissions -rw-r--r--
Adding support for concurrent overriden standard function
Adding support for generate initial values
Adding support for expression into FBD variables
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
     1
#!/usr/bin/env python
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
     3
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
     4
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
     5
#based on the plcopen standard. 
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
     6
#
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
     7
#Copyright (C): Edouard TISSERANT and Laurent BESSARD
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
     8
#
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
     9
#See COPYING file for copyrights details.
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    10
#
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    11
#This library is free software; you can redistribute it and/or
5
f8652b073e84 GPL->LGPL
etisserant
parents: 4
diff changeset
    12
#modify it under the terms of the GNU General Public
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    13
#License as published by the Free Software Foundation; either
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    14
#version 2.1 of the License, or (at your option) any later version.
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    15
#
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    16
#This library is distributed in the hope that it will be useful,
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    17
#but WITHOUT ANY WARRANTY; without even the implied warranty of
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    18
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    19
#Lesser General Public License for more details.
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    20
#
5
f8652b073e84 GPL->LGPL
etisserant
parents: 4
diff changeset
    21
#You should have received a copy of the GNU General Public
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    22
#License along with this library; if not, write to the Free Software
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    23
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    24
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    25
from minixsv import pyxsval
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
    26
from xml.dom import minidom
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    27
import cPickle
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    28
import os,sys,re
24
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
    29
from datetime import *
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    30
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    31
from plcopen import plcopen
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    32
from plcopen.structures import *
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    33
from graphics.GraphicCommons import *
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    34
from PLCGenerator import *
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    35
24
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
    36
duration_model = re.compile("(?:([0-9]{1,2})h)?(?:([0-9]{1,2})m)?(?:([0-9]{1,2})s)?(?:([0-9]{1,3})ms)?")
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
    37
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    38
[ITEM_UNEDITABLE, ITEM_PROJECT, ITEM_POU, ITEM_CLASS, ITEM_VARIABLE,
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    39
 ITEM_TRANSITION, ITEM_ACTION, ITEM_CONFIGURATION, ITEM_RESOURCE] = range(9)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    40
2
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    41
"""
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    42
pyxsval is not complete and the parts that are not supported print some error
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    43
reports. This class is used for not displaying them
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    44
"""
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    45
class HolePseudoFile:
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    46
    """ Base class for file like objects to facilitate StdOut for the Shell."""
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    47
    def __init__(self, output = None):
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    48
        if output is None: output = []
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    49
        self.output = output
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    50
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    51
    def writelines(self, l):
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    52
        map(self.write, l)
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    53
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    54
    def write(self, s):
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    55
        pass
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    56
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    57
    def flush(self):
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    58
        pass
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    59
    
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    60
    def isatty(self):
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    61
        return false
93bc4c2cf376 PLCGenerator finished
lbessard
parents: 0
diff changeset
    62
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    63
#-------------------------------------------------------------------------------
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    64
#                         Undo Buffer for PLCOpenEditor
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    65
#-------------------------------------------------------------------------------
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    66
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    67
# Length of the buffer
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    68
UNDO_BUFFER_LENGTH = 20
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    69
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    70
"""
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    71
Class implementing a buffer of changes made on the current editing Object Dictionary
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    72
"""
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    73
class UndoBuffer:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    74
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    75
    # Constructor initialising buffer
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    76
    def __init__(self, currentstate, issaved = False):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    77
        self.Buffer = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    78
        self.CurrentIndex = -1
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    79
        self.MinIndex = -1
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    80
        self.MaxIndex = -1
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    81
        # if current state is defined
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    82
        if currentstate:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    83
            self.CurrentIndex = 0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    84
            self.MinIndex = 0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    85
            self.MaxIndex = 0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    86
        # Initialising buffer with currentstate at the first place
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    87
        for i in xrange(UNDO_BUFFER_LENGTH):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    88
            if i == 0:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    89
                self.Buffer.append(currentstate)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    90
            else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    91
                self.Buffer.append(None)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    92
        # Initialising index of state saved
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    93
        if issaved:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    94
            self.LastSave = 0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    95
        else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    96
            self.LastSave = -1
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    97
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    98
    # Add a new state in buffer
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
    99
    def Buffering(self, currentstate):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   100
        self.CurrentIndex = (self.CurrentIndex + 1) % UNDO_BUFFER_LENGTH
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   101
        self.Buffer[self.CurrentIndex] = currentstate
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   102
        # Actualising buffer limits
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   103
        self.MaxIndex = self.CurrentIndex
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   104
        if self.MinIndex == self.CurrentIndex:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   105
            # If the removed state was the state saved, there is no state saved in the buffer
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   106
            if self.LastSave == self.MinIndex:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   107
                self.LastSave = -1
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   108
            self.MinIndex = (self.MinIndex + 1) % UNDO_BUFFER_LENGTH
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   109
        self.MinIndex = max(self.MinIndex, 0)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   110
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   111
    # Return current state of buffer
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   112
    def Current(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   113
        return self.Buffer[self.CurrentIndex]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   114
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   115
    # Change current state to previous in buffer and return new current state
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   116
    def Previous(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   117
        if self.CurrentIndex != self.MinIndex:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   118
            self.CurrentIndex = (self.CurrentIndex - 1) % UNDO_BUFFER_LENGTH
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   119
            return self.Buffer[self.CurrentIndex]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   120
        return None
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   121
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   122
    # Change current state to next in buffer and return new current state
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   123
    def Next(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   124
        if self.CurrentIndex != self.MaxIndex:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   125
            self.CurrentIndex = (self.CurrentIndex + 1) % UNDO_BUFFER_LENGTH
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   126
            return self.Buffer[self.CurrentIndex]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   127
        return None
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   128
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   129
    # Return True if current state is the first in buffer
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   130
    def IsFirst(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   131
        return self.CurrentIndex == self.MinIndex
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   132
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   133
    # Return True if current state is the last in buffer
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   134
    def IsLast(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   135
        return self.CurrentIndex == self.MaxIndex
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   136
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   137
    # Note that current state is saved
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   138
    def CurrentSaved(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   139
        self.LastSave = self.CurrentIndex
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   140
        
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   141
    # Return True if current state is saved
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   142
    def IsCurrentSaved(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   143
        return self.LastSave == self.CurrentIndex
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   144
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   145
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   146
#-------------------------------------------------------------------------------
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   147
#                           Controler for PLCOpenEditor
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   148
#-------------------------------------------------------------------------------
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   149
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   150
"""
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   151
Class which controls the operations made on the plcopen model and answers to view requests
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   152
"""
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   153
class PLCControler:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   154
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   155
    # Create a new PLCControler
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   156
    def __init__(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   157
        self.LastNewIndex = 0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   158
        self.Reset()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   159
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   160
    # Reset PLCControler internal variables
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   161
    def Reset(self):
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
   162
        self.VerifyXML = False
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   163
        self.Project = None
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   164
        self.ProjectBuffer = None
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   165
        self.FilePath = ""
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   166
        self.FileName = ""
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   167
        self.ElementsOpened = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   168
        self.CurrentElementEditing = None
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   169
        self.RefreshPouUsingTree()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   170
        self.RefreshBlockTypes()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   171
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   172
    def GetQualifierTypes(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   173
        return plcopen.QualifierList
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   174
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   175
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   176
#-------------------------------------------------------------------------------
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   177
#                         Project management functions
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   178
#-------------------------------------------------------------------------------
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   179
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   180
    # Return if a project is opened
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   181
    def HasOpenedProject(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   182
        return self.Project != None
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   183
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   184
    # Create a new project by replacing the current one
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   185
    def CreateNewProject(self, name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   186
        # Create the project
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   187
        self.Project = plcopen.project()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   188
        self.Project.setName(name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   189
        # Initialize the project buffer
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
   190
        #self.ProjectBuffer = UndoBuffer(self.Copy(self.Project))
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   191
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   192
    # Change project name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   193
    def SetProjectName(self, name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   194
        self.Project.setName(name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   195
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   196
    # Return project name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   197
    def GetProjectName(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   198
        return self.Project.getName()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   199
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   200
    # Return project pou names
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   201
    def GetProjectPouNames(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   202
        return [pou.getName() for pou in self.Project.getPous()]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   203
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   204
    # Return project pou names
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   205
    def GetProjectConfigNames(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   206
        return [config.getName() for config in self.Project.getConfigurations()]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   207
    
6
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   208
    # Return project pou variables
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   209
    def GetProjectPouVariables(self, pou_name=None):
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   210
        variables = []
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   211
        for pou in self.Project.getPous():
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   212
            if not pou_name or pou_name == pou.getName():
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   213
                variables.extend([var["Name"] for var in self.GetPouInterfaceVars(pou)])
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   214
                if pou.getBodyType() == "SFC":
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   215
                    for transition in pou.getTransitionList():
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   216
                        variables.append(transition.getName())
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   217
                    for action in pou.getActionList():
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   218
                        variables.append(action.getName())
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   219
        return variables
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   220
    
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   221
    # Return file path if project is an open file
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   222
    def GetFilePath(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   223
        return self.FilePath
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   224
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   225
    # Return file name and point out if file is up to date
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   226
    def GetFilename(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   227
        if self.ProjectBuffer.IsCurrentSaved():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   228
            return self.FileName
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   229
        else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   230
            return "~%s~"%self.FileName
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   231
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   232
    # Change file path and save file name or create a default one if file path not defined
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   233
    def SetFilePath(self, filepath):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   234
        self.FilePath = filepath
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   235
        if filepath == "":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   236
            self.LastNewIndex += 1
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   237
            self.FileName = "Unnamed%d"%self.LastNewIndex
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   238
        else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   239
            self.FileName = os.path.splitext(os.path.basename(filepath))[0]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   240
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   241
    # Change project properties
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   242
    def SetProjectProperties(self, values):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   243
        self.Project.setFileHeader(values)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   244
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   245
    # Return project properties
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   246
    def GetProjectProperties(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   247
        return self.Project.getFileHeader()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   248
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   249
    # Return project informations
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   250
    def GetProjectInfos(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   251
        if self.Project:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   252
            infos = {"name": self.Project.getName(), "type": ITEM_PROJECT}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   253
            pou_types = {"function": {"name": "Functions", "type": ITEM_UNEDITABLE, "values":[]},
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   254
                         "functionBlock": {"name": "Function Blocks", "type": ITEM_UNEDITABLE, "values":[]},
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   255
                         "program": {"name": "Programs", "type": ITEM_UNEDITABLE, "values":[]}}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   256
            for pou in self.Project.getPous():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   257
                pou_type = pou.getPouType().getValue()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   258
                pou_infos = {"name": pou.getName(), "type": ITEM_POU}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   259
                var_types = {"Input": {"name": "Input", "type": ITEM_CLASS, "values": []},
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   260
                         "Output": {"name": "Output", "type": ITEM_CLASS, "values": []},
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   261
                         "InOut": {"name": "InOut", "type": ITEM_CLASS, "values": []},
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   262
                         "External": {"name": "External", "type": ITEM_CLASS, "values": []},
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   263
                         "Local": {"name": "Local", "type": ITEM_CLASS, "values": []},
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   264
                         "Temp": {"name": "Temp", "type": ITEM_CLASS, "values": []},
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   265
                         "Global": {"name": "Global", "type": ITEM_CLASS, "values": []}}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   266
                for var in self.GetPouInterfaceVars(pou):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   267
                    var_values = {"name": var["Name"], "type": ITEM_VARIABLE, "values": []}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   268
                    if var["Class"] in var_types.keys():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   269
                        var_types[var["Class"]]["values"].append(var_values)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   270
                pou_values = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   271
                pou_values.append({"name": "Interface", "type": ITEM_CLASS, 
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   272
                    "values": [var_types["Input"], var_types["Output"], var_types["InOut"], var_types["External"]]})
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   273
                pou_values.append({"name": "Variables", "type": ITEM_CLASS, 
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   274
                    "values": [var_types["Local"], var_types["Temp"]]})
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   275
                if pou_type == "program":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   276
                    pou_values.append(var_types["Global"])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   277
                if pou.getBodyType() == "SFC":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   278
                    transitions = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   279
                    for transition in pou.getTransitionList():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   280
                        transitions.append({"name": transition.getName(), "type": ITEM_TRANSITION, "values": []})
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   281
                    pou_values.append({"name": "Transitions", "type": ITEM_UNEDITABLE, "values": transitions})
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   282
                    actions = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   283
                    for action in pou.getActionList():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   284
                        actions.append({"name": action.getName(), "type": ITEM_ACTION, "values": []})
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   285
                    pou_values.append({"name": "Actions", "type": ITEM_UNEDITABLE, "values": actions})
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   286
                if pou_type in pou_types:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   287
                    pou_infos["values"] = pou_values
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   288
                    pou_types[pou_type]["values"].append(pou_infos)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   289
            configurations = {"name": "Configurations", "type": ITEM_UNEDITABLE, "values": []}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   290
            for config in self.Project.getConfigurations():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   291
                config_name = config.getName()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   292
                config_infos = {"name": config_name, "type": ITEM_CONFIGURATION, "values": []}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   293
                config_vars = {"name": "Global", "type": ITEM_CLASS, "values": []}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   294
                for var in self.GetConfigurationGlobalVars(config_name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   295
                    var_values = {"name": var["Name"], "type": ITEM_VARIABLE, "values": []}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   296
                    config_vars["values"].append(var_values)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   297
                resources = {"name": "Resources", "type": ITEM_UNEDITABLE, "values": []}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   298
                for resource in config.getResource():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   299
                    resource_name = resource.getName()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   300
                    resource_infos = {"name": resource_name, "type": ITEM_RESOURCE, "values": []}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   301
                    resource_vars = {"name": "Global", "type": ITEM_CLASS, "values": []}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   302
                    for var in self.GetConfigurationResourceGlobalVars(config_name, resource_name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   303
                        var_values = {"name": var["Name"], "type": ITEM_VARIABLE, "values": []}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   304
                        resource_vars["values"].append(var_values)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   305
                    resource_infos["values"].append(resource_vars)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   306
                    resources["values"].append(resource_infos)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   307
                config_infos["values"] = [config_vars, resources]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   308
                configurations["values"].append(config_infos)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   309
            infos["values"] = [{"name": "Properties", "type": ITEM_UNEDITABLE, "values": []},
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   310
                               pou_types["function"], pou_types["functionBlock"], 
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   311
                               pou_types["program"], configurations]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   312
            return infos
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   313
        return None
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   314
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   315
    # Refresh the tree of user-defined pou cross-use
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   316
    def RefreshPouUsingTree(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   317
        # Reset the tree of user-defined pou cross-use
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   318
        self.PouUsingTree = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   319
        if self.Project:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   320
            pous = self.Project.getPous()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   321
            # Reference all the user-defined pou names and initialize the tree of 
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   322
            # user-defined pou cross-use
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   323
            pounames = [pou.getName() for pou in pous]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   324
            for name in pounames:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   325
                self.PouUsingTree[name] = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   326
            # Analyze each pou 
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   327
            for pou in pous:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   328
                name = pou.getName()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   329
                bodytype = pou.getBodyType()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   330
                # If pou is written in a graphical language
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   331
                if bodytype in ["FBD","LD","SFC"]:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   332
                    # Analyze each instance of the pou
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   333
                    for instance in pou.getInstances():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   334
                        if isinstance(instance, plcopen.block):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   335
                            typename = instance.getTypeName()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   336
                            # Update tree if there is a cross-use
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   337
                            if typename in pounames and name not in self.PouUsingTree[typename]:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   338
                                 self.PouUsingTree[typename].append(name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   339
                # If pou is written in a textual language
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   340
                elif bodytype in ["IL", "ST"]:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   341
                    text = pou.getText()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   342
                    # Search if each pou is mentioned in the pou text
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   343
                    for typename in pounames:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   344
                        typename_model = re.compile("[ \t\n]%s[ \t\n]"%typename)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   345
                        # Update tree if there is a cross-use
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   346
                        if typename != name and typename_model.search(text):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   347
                            self.PouUsingTree[typename].append(name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   348
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   349
    # Return if pou given by name is used by another pou
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   350
    def PouIsUsed(self, name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   351
        if name in self.PouUsingTree:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   352
            return len(self.PouUsingTree[name]) > 0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   353
        return False
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   354
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   355
    # Return if pou given by name is directly or undirectly used by the reference pou
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   356
    def PouIsUsedBy(self, name, reference):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   357
        if name in self.PouUsingTree:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   358
            list = self.PouUsingTree[name]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   359
            # Test if pou is directly used by reference
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   360
            if reference in list:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   361
                return True
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   362
            else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   363
                # Test if pou is undirectly used by reference, by testing if pous 
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   364
                # that directly use pou is directly or undirectly used by reference
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   365
                used = False
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   366
                for element in list:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   367
                    used |= self.PouIsUsedBy(element, reference)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   368
                return used
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   369
        return False
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   370
4
2de7fd952fdd Adding File Dialog for choosing path to generated program
lbessard
parents: 2
diff changeset
   371
    def GenerateProgram(self, filepath):
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   372
        if self.Project:
28
fc23e1f415d8 Adding support for concurrent overriden standard function
lbessard
parents: 27
diff changeset
   373
            #try:
fc23e1f415d8 Adding support for concurrent overriden standard function
lbessard
parents: 27
diff changeset
   374
            program = GenerateCurrentProgram(self.Project)
fc23e1f415d8 Adding support for concurrent overriden standard function
lbessard
parents: 27
diff changeset
   375
            programfile = open(filepath, "w")
fc23e1f415d8 Adding support for concurrent overriden standard function
lbessard
parents: 27
diff changeset
   376
            programfile.write(program)
fc23e1f415d8 Adding support for concurrent overriden standard function
lbessard
parents: 27
diff changeset
   377
            programfile.close()
fc23e1f415d8 Adding support for concurrent overriden standard function
lbessard
parents: 27
diff changeset
   378
            return True
fc23e1f415d8 Adding support for concurrent overriden standard function
lbessard
parents: 27
diff changeset
   379
            #except:
fc23e1f415d8 Adding support for concurrent overriden standard function
lbessard
parents: 27
diff changeset
   380
            #    pass
4
2de7fd952fdd Adding File Dialog for choosing path to generated program
lbessard
parents: 2
diff changeset
   381
        return False
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   382
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   383
#-------------------------------------------------------------------------------
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   384
#                        Project Pous management functions
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   385
#-------------------------------------------------------------------------------
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   386
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   387
    # Add a Pou to Project
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   388
    def ProjectAddPou(self, name, pou_type, body_type):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   389
        # Add the pou to project
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   390
        self.Project.appendPou(name, pou_type, body_type)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   391
        self.RefreshPouUsingTree()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   392
        self.RefreshBlockTypes()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   393
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   394
    # Remove a pou from project
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   395
    def ProjectRemovePou(self, name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   396
        removed = None
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   397
        # Search if the pou removed is currently opened
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   398
        for i, pou in enumerate(self.ElementsOpened):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   399
            if pou == name:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   400
                removed = i
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   401
        # If found, remove pou from list of opened pous and actualize current edited
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   402
        if removed != None:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   403
            self.ElementsOpened.pop(removed)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   404
            if self.CurrentElementEditing > removed:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   405
                self.CurrentElementEditing -= 1
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   406
            if len(self.ElementsOpened) > 0:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   407
                self.CurrentElementEditing = max(0, min(self.CurrentElementEditing, len(self.ElementsOpened) - 1))
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   408
            else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   409
                self.CurrentElementEditing = None
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   410
        # Remove pou from project
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   411
        self.Project.removePou(name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   412
        self.RefreshPouUsingTree()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   413
        self.RefreshBlockTypes()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   414
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   415
    # Add a configuration to Project
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   416
    def ProjectAddConfiguration(self, name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   417
        self.Project.addConfiguration(name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   418
        self.RefreshPouUsingTree()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   419
        self.RefreshBlockTypes()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   420
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   421
    # Remove a configuration from project
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   422
    def ProjectRemoveConfiguration(self, name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   423
        self.Project.removeConfiguration(name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   424
        self.RefreshPouUsingTree()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   425
        self.RefreshBlockTypes()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   426
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   427
    # Add a resource to a configuration of the Project
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   428
    def ProjectAddConfigurationResource(self, config, name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   429
        self.Project.addConfigurationResource(config, name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   430
        self.RefreshPouUsingTree()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   431
        self.RefreshBlockTypes()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   432
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   433
    # Remove a resource from a configuration of the project
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   434
    def ProjectRemoveConfigurationResource(self, config, name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   435
        self.Project.removeConfigurationResource(config, name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   436
        self.RefreshPouUsingTree()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   437
        self.RefreshBlockTypes()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   438
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   439
    # Add a Transition to a Project Pou
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   440
    def ProjectAddPouTransition(self, pou_name, transition_name, transition_type):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   441
        pou = self.Project.getPou(pou_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   442
        pou.addTransition(transition_name, transition_type)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   443
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   444
    # Add a Transition to a Project Pou
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   445
    def ProjectAddPouAction(self, pou_name, action_name, action_type):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   446
        pou = self.Project.getPou(pou_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   447
        pou.addAction(action_name, action_type)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   448
        
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   449
    # Change the name of a pou
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   450
    def ChangePouName(self, old_name, new_name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   451
        # Found the pou corresponding to old name and change its name to new name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   452
        pou = self.Project.getPou(old_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   453
        pou.setName(new_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   454
        # If pou is currently opened, change its name in the list of opened pous
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   455
        if old_name in self.ElementsOpened:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   456
            idx = self.ElementsOpened.index(old_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   457
            self.ElementsOpened[idx] = new_name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   458
        self.RefreshPouUsingTree()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   459
        self.RefreshBlockTypes()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   460
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   461
    # Change the name of a pou transition
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   462
    def ChangePouTransitionName(self, pou_name, old_name, new_name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   463
        # Found the pou transition corresponding to old name and change its name to new name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   464
        pou = self.Project.getPou(pou_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   465
        transition = pou.getTransition(old_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   466
        transition.setName(new_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   467
        # If pou transition is currently opened, change its name in the list of opened elements
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   468
        old_computedname = self.ComputePouTransitionName(pou_name, old_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   469
        new_computedname = self.ComputePouTransitionName(pou_name, new_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   470
        if old_computedname in self.ElementsOpened:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   471
            idx = self.ElementsOpened.index(old_computedname)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   472
            self.ElementsOpened[idx] = new_computedname
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   473
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   474
    # Change the name of a pou action
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   475
    def ChangePouActionName(self, pou_name, old_name, new_name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   476
        # Found the pou action corresponding to old name and change its name to new name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   477
        pou = self.Project.getPou(pou_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   478
        action = pou.getAction(old_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   479
        action.setName(new_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   480
        # If pou action is currently opened, change its name in the list of opened elements
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   481
        old_computedname = self.ComputePouActionName(pou_name, old_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   482
        new_computedname = self.ComputePouActionName(pou_name, new_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   483
        if old_computedname in self.ElementsOpened:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   484
            idx = self.ElementsOpened.index(old_computedname)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   485
            self.ElementsOpened[idx] = new_computedname
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   486
6
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   487
    # Change the name of a pou action
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   488
    def ChangePouVariableName(self, pou_name, old_name, new_name):
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   489
        # Found the pou action corresponding to old name and change its name to new name
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   490
        pou = self.Project.getPou(pou_name)
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   491
        for type, varlist in pou.getVars():
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   492
            for var in varlist.getVariable():
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   493
                if var.getName() == old_name:
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   494
                    var.setName(new_name)
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   495
        self.RefreshBlockTypes()
c8cf918ee7ea Bug corrected and improvements
lbessard
parents: 5
diff changeset
   496
        
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   497
    # Change the name of a configuration
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   498
    def ChangeConfigurationName(self, old_name, new_name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   499
        # Found the configuration corresponding to old name and change its name to new name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   500
        configuration = self.Project.getConfiguration(old_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   501
        configuration.setName(new_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   502
        # If configuration is currently opened, change its name in the list of opened elements
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   503
        for idx, element in enumerate(self.ElementsOpened):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   504
            self.ElementsOpened[idx] = element.replace(old_name, new_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   505
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   506
    # Change the name of a configuration resource
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   507
    def ChangeConfigurationResourceName(self, config_name, old_name, new_name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   508
        # Found the resource corresponding to old name and change its name to new name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   509
        resource = self.Project.getConfigurationResource(config_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   510
        resource.setName(new_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   511
        # If resource is currently opened, change its name in the list of opened elements
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   512
        old_computedname = self.ComputeConfigurationResourceName(config_name, old_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   513
        new_computedname = self.ComputeConfigurationResourceName(config_name, new_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   514
        if old_computedname in self.ElementsOpened:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   515
            idx = self.ElementsOpened.index(old_computedname)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   516
            self.ElementsOpened[idx] = new_computedname
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   517
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   518
    # Return the type of the pou given by its name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   519
    def GetPouType(self, name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   520
        # Found the pou correponding to name and return its type
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   521
        pou = self.Project.getPou(name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   522
        return pou.pouType.getValue()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   523
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   524
    # Return pous with SFC language
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   525
    def GetSFCPous(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   526
        list = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   527
        if self.Project:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   528
            for pou in self.Project.getPous():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   529
                if pou.getBodyType() == "SFC":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   530
                    list.append(pou.getName())
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   531
        return list
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   532
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   533
    # Return the body language of the pou given by its name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   534
    def GetPouBodyType(self, name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   535
        # Found the pou correponding to name and return its body language
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   536
        pou = self.Project.getPou(name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   537
        return pou.getBodyType()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   538
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   539
    # Return the body language of the transition given by its name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   540
    def GetTransitionBodyType(self, pou_name, pou_transition):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   541
        # Found the pou correponding to name and return its body language
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   542
        pou = self.Project.getPou(pou_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   543
        transition = pou.getTransition(pou_transition)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   544
        return transition.getBodyType()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   545
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   546
    # Return the body language of the pou given by its name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   547
    def GetActionBodyType(self, pou_name, pou_action):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   548
        # Found the pou correponding to name and return its body language
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   549
        pou = self.Project.getPou(pou_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   550
        action = pou.getAction(pou_action)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   551
        return action.getBodyType()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   552
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   553
    # Extract varlists from a list of vars
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   554
    def ExtractVarLists(self, vars):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   555
        varlist_list = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   556
        current_varlist = None
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   557
        current_type = None
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   558
        for var in vars:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   559
            if current_type != (var["Class"], var["Retain"], var["Constant"]):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   560
                current_type = (var["Class"], var["Retain"], var["Constant"])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   561
                current_varlist = plcopen.varList()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   562
                varlist_list.append((var["Class"], current_varlist))
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   563
                if var["Retain"] == "Yes":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   564
                    varlist.setRetain(True)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   565
                if var["Constant"] == "Yes":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   566
                    varlist.setConstant(True)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   567
            # Create variable and change its properties
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   568
            tempvar = plcopen.varListPlain_variable()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   569
            tempvar.setName(var["Name"])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   570
            var_type = plcopen.dataType()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   571
            var_type.setValue(var["Type"])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   572
            tempvar.setType(var_type)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   573
            if var["Initial Value"] != "":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   574
                value = plcopen.value()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   575
                value.setValue(var["Initial Value"])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   576
                tempvar.setInitialValue(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   577
            if var["Location"] != "":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   578
                tempvar.setAddress(var["Location"])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   579
            # Add variable to varList
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   580
            current_varlist.appendVariable(tempvar)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   581
        return varlist_list
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   582
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   583
    # Replace the configuration globalvars by those given
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   584
    def SetConfigurationGlobalVars(self, name, vars):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   585
        # Found the configuration corresponding to name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   586
        configuration = self.Project.getConfiguration(name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   587
        if configuration:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   588
            # Set configuration global vars
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   589
            configuration.setGlobalVars([])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   590
            for vartype, varlist in self.ExtractVarLists(vars):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   591
                configuration.globalVars.append(varlist)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   592
        self.RefreshBlockTypes()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   593
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   594
    # Return the configuration globalvars
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   595
    def GetConfigurationGlobalVars(self, name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   596
        vars = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   597
        # Found the configuration corresponding to name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   598
        configuration = self.Project.getConfiguration(name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   599
        if configuration:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   600
            # Extract variables from every varLists
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   601
            for varlist in configuration.getGlobalVars():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   602
                for var in varlist.getVariable():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   603
                    tempvar = {"Name":var.getName(),"Class":"Global","Type":var.getType().getValue(),
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   604
                        "Location":var.getAddress()}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   605
                    initial = var.getInitialValue()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   606
                    if initial:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   607
                        tempvar["Initial Value"] = initial.getValue()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   608
                    else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   609
                        tempvar["Initial Value"] = ""
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   610
                    if varlist.getRetain():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   611
                        tempvar["Retain"] = "Yes"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   612
                    else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   613
                        tempvar["Retain"] = "No"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   614
                    if varlist.getConstant():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   615
                        tempvar["Constant"] = "Yes"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   616
                    else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   617
                        tempvar["Constant"] = "No"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   618
                    vars.append(tempvar)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   619
        return vars
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   620
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   621
    # Replace the resource globalvars by those given
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   622
    def SetConfigurationResourceGlobalVars(self, config_name, name, vars):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   623
        # Found the resource corresponding to name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   624
        resource = self.Project.getConfigurationResource(config_name, name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   625
        # Set resource global vars
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   626
        if resource:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   627
            resource.setGlobalVars([])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   628
            for vartype, varlist in self.ExtractVarLists(vars):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   629
                resource.globalVars.append(varlist)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   630
        self.RefreshBlockTypes()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   631
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   632
    # Return the resource globalvars
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   633
    def GetConfigurationResourceGlobalVars(self, config_name, name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   634
        vars = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   635
        # Found the resource corresponding to name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   636
        resource = self.Project.getConfigurationResource(config_name, name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   637
        if resource:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   638
            # Extract variables from every varLists
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   639
            for varlist in resource.getGlobalVars():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   640
                for var in varlist.getVariable():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   641
                    tempvar = {"Name":var.getName(),"Class":"Global","Type":var.getType().getValue(),
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   642
                        "Location":var.getAddress()}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   643
                    initial = var.getInitialValue()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   644
                    if initial:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   645
                        tempvar["Initial Value"] = initial.getValue()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   646
                    else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   647
                        tempvar["Initial Value"] = ""
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   648
                    if varlist.getRetain():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   649
                        tempvar["Retain"] = "Yes"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   650
                    else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   651
                        tempvar["Retain"] = "No"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   652
                    if varlist.getConstant():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   653
                        tempvar["Constant"] = "Yes"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   654
                    else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   655
                        tempvar["Constant"] = "No"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   656
                    vars.append(tempvar)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   657
        return vars
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   658
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   659
    # Return the interface of the pou given by its name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   660
    def GetPouInterfaceVarsByName(self, name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   661
        # Found the pou correponding to name and return the interface
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   662
        return self.GetPouInterfaceVars(self.Project.getPou(name))
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   663
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   664
    # Return the interface for the given pou
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   665
    def GetPouInterfaceVars(self, pou):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   666
        vars = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   667
        # Verify that the pou has an interface
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   668
        if pou.interface:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   669
            # Extract variables from every varLists
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   670
            for type, varlist in pou.getVars():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   671
                for var in varlist.getVariable():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   672
                    tempvar = {"Name":var.getName(),"Class":type,"Type":var.getType().getValue(),
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   673
                        "Location":var.getAddress()}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   674
                    initial = var.getInitialValue()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   675
                    if initial:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   676
                        tempvar["Initial Value"] = initial.getValue()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   677
                    else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   678
                        tempvar["Initial Value"] = ""
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   679
                    if varlist.getRetain():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   680
                        tempvar["Retain"] = "Yes"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   681
                    else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   682
                        tempvar["Retain"] = "No"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   683
                    if varlist.getConstant():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   684
                        tempvar["Constant"] = "Yes"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   685
                    else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   686
                        tempvar["Constant"] = "No"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   687
                    vars.append(tempvar)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   688
        return vars
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   689
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   690
    # Replace the Pou interface by the one given
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   691
    def SetPouInterfaceVars(self, name, vars):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   692
        # Found the pou corresponding to name and add interface if there isn't one yet
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   693
        pou = self.Project.getPou(name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   694
        if not pou.interface:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   695
            pou.interface = plcopen.pou_interface()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   696
        # Set Pou interface
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   697
        pou.setVars(self.ExtractVarLists(vars))
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   698
        self.RefreshBlockTypes()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   699
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   700
    # Replace the return type of the pou given by its name (only for functions)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   701
    def SetPouInterfaceReturnType(self, name, type):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   702
        pou = self.Project.getPou(name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   703
        if not pou.interface:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   704
            pou.interface = plcopen.pou_interface()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   705
        # If there isn't any return type yet, add it
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   706
        return_type = pou.interface.getReturnType()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   707
        if not return_type:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   708
            return_type = plcopen.dataType()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   709
            pou.interface.setReturnType(return_type)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   710
        # Change return type
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   711
        return_type.setValue(type)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   712
        self.RefreshBlockTypes()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   713
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   714
    # Return the return type of the pou given by its name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   715
    def GetPouInterfaceReturnTypeByName(self, name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   716
        # Found the pou correponding to name and return the return type
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   717
        return self.GetPouInterfaceReturnType(self.Project.getPou(name))
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   718
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   719
    # Return the return type of the given pou
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   720
    def GetPouInterfaceReturnType(self, pou):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   721
        # Verify that the pou has an interface
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   722
        if pou.interface:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   723
            # Return the return type if there is one
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   724
            return_type = pou.interface.getReturnType()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   725
            if return_type:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   726
                return return_type.getValue()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   727
        return None
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   728
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   729
    # Update Block types with user-defined pou added
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   730
    def RefreshBlockTypes(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   731
        if BlockTypes[-1]["name"] == "User-defined POUs":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   732
            BlockTypes[-1]["list"] = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   733
        else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   734
            BlockTypes.append({"name" : "User-defined POUs", "list": []})
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   735
        if self.Project:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   736
            for pou in self.Project.getPous():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   737
                pou_name = pou.getName()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   738
                pou_type = pou.pouType.getValue()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   739
                if pou_type != "program":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   740
                    block_infos = {"name" : pou_name, "type" : pou_type, "extensible" : False,
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   741
                                   "inputs" : [], "outputs" : [], "comment" : ""}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   742
                    if pou.getInterface():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   743
                        for type, varlist in pou.getVars():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   744
                            if type == "InOut":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   745
                                for var in varlist.getVariable():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   746
                                    block_infos["inputs"].append((var.getName(),var.getType().getValue(),"none"))
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   747
                                    block_infos["outputs"].append((var.getName(),var.getType().getValue(),"none"))
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   748
                            elif type == "Input":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   749
                                for var in varlist.getVariable():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   750
                                    block_infos["inputs"].append((var.getName(),var.getType().getValue(),"none"))
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   751
                            elif type == "Output":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   752
                                for var in varlist.getVariable():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   753
                                    block_infos["outputs"].append((var.getName(),var.getType().getValue(),"none"))
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   754
                        return_type = pou.interface.getReturnType()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   755
                        if return_type:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   756
                            block_infos["outputs"].append(("",return_type.getValue(),"none"))
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   757
                    if pou.getBodyType() in ["FBD","LD","SFC"]:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   758
                        for instance in pou.getInstances():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   759
                            if isinstance(instance, plcopen.comment):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   760
                                block_infos["comment"] = instance.getContentText()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   761
                    BlockTypes[-1]["list"].append(block_infos)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   762
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   763
    # Return Block types checking for recursion
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   764
    def GetBlockTypes(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   765
        if self.CurrentElementEditing != None:
13
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   766
            if self.Project:
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   767
                current_name = self.ElementsOpened[self.CurrentElementEditing]
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   768
                words = current_name.split("::")
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   769
                if len(words) == 1:
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   770
                    name = current_name
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   771
                else:
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   772
                    name = words[1]
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   773
                type = self.GetPouType(name)
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   774
            else:
13
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   775
                name = ""
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   776
                type = None
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   777
            if type == "function":
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   778
                blocktypes = []
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   779
                for category in BlockTypes[:-1]:
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   780
                    cat = {"name" : category["name"], "list" : []}
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   781
                    for block in category["list"]:
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   782
                        if block["type"] == "function":
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   783
                            cat["list"].append(block)
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   784
                    if len(cat["list"]) > 0:
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   785
                        blocktypes.append(cat)
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   786
            else:
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   787
                blocktypes = [category for category in BlockTypes[:-1]]
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   788
            if self.Project:
13
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   789
                blocktypes.append({"name" : "User-defined POUs", "list": []})
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   790
                for blocktype in BlockTypes[-1]["list"]:
13
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   791
                    if blocktype["name"] != name and not self.PouIsUsedBy(name, blocktype["name"]) and not (type == "function" and blocktype["type"] != "function"):
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   792
                        blocktypes[-1]["list"].append(blocktype)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   793
            return blocktypes
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   794
        return []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   795
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   796
    # Return Block types checking for recursion
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   797
    def GetBlockResource(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   798
        blocktypes = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   799
        for category in BlockTypes[:-1]:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   800
            for blocktype in category["list"]:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   801
                if blocktype["type"] != "function":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   802
                    blocktypes.append(blocktype["name"])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   803
        if self.Project:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   804
            for pou in self.Project.getPous():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   805
                if pou.pouType.getValue() != "function":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   806
                    blocktypes.append(pou.getName())
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   807
        return blocktypes
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   808
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   809
#-------------------------------------------------------------------------------
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   810
#                       Project opened Pous management functions
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   811
#-------------------------------------------------------------------------------
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   812
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   813
    # Return the list of pou names
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   814
    def GetElementsOpenedNames(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   815
        names = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   816
        for pou_name in self.ElementsOpened:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   817
            words = pou_name.split("::")
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   818
            if len(words) == 1:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   819
                names.append(pou_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   820
            else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   821
                names.append("%s-%s"%(words[1],words[2]))
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   822
        return names
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   823
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   824
    # Compute a pou transition name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   825
    def ComputePouTransitionName(self, pou, transition):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   826
        return "T::%s::%s" % (pou, transition)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   827
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   828
    # Compute a pou action name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   829
    def ComputePouActionName(self, pou, action):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   830
        return "A::%s::%s" % (pou, action)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   831
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   832
    # Compute a pou  name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   833
    def ComputeConfigurationResourceName(self, config, resource):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   834
        return "R::%s::%s" % (config, resource)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   835
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   836
    # Open a pou by giving its name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   837
    def OpenElementEditing(self, name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   838
        # If pou not opened yet
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   839
        if name not in self.ElementsOpened:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   840
            # Add pou name to list of pou opened and make it current editing
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   841
            self.ElementsOpened.append(name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   842
            self.CurrentElementEditing = len(self.ElementsOpened) - 1
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   843
            return self.CurrentElementEditing
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   844
        return None
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   845
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   846
    # Open a pou transition by giving pou and transition names
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   847
    def OpenPouTransitionEditing(self, pou, transition):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   848
        return self.OpenElementEditing(self.ComputePouTransitionName(pou, transition))
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   849
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   850
    # Open a pou action by giving pou and action names
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   851
    def OpenPouActionEditing(self, pou, action):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   852
        return self.OpenElementEditing(self.ComputePouActionName(pou, action))
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   853
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   854
    # Open a configuration resource by giving configuration and resource names
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   855
    def OpenConfigurationResourceEditing(self, config, resource):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   856
        return self.OpenElementEditing(self.ComputeConfigurationResourceName(config, resource))
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   857
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   858
    # Return if pou given by name is opened
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   859
    def IsElementEditing(self, name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   860
        return name in self.ElementsOpened
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   861
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   862
    # Return if pou transition given by pou and transition names is opened
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   863
    def IsPouTransitionEditing(self, pou, transition):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   864
        return self.ComputePouTransitionName(pou, transition) in self.ElementsOpened
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   865
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   866
    # Return if pou action given by pou and action names is opened
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   867
    def IsPouActionEditing(self, pou, action):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   868
        return self.ComputePouActionName(pou, action) in self.ElementsOpened
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   869
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   870
    # Return if pou action given by pou and action names is opened
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   871
    def IsConfigurationResourceEditing(self, pou, action):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   872
        return self.ComputeConfigurationResourceName(config, resource) in self.ElementsOpened
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   873
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   874
    # Close current pou editing
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   875
    def CloseElementEditing(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   876
        # Remove pou from list of pou opened
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   877
        self.ElementsOpened.pop(self.CurrentElementEditing)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   878
        # Update index of current pou editing
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   879
        if len(self.ElementsOpened) > 0:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   880
            self.CurrentElementEditing = min(self.CurrentElementEditing, len(self.ElementsOpened) - 1)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   881
        else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   882
            self.CurrentElementEditing = None
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   883
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   884
    # Change current pou editing for pou given by name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   885
    def ChangeElementEditing(self, name):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   886
        # Verify that pou is opened
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   887
        if name in self.ElementsOpened:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   888
            # Change current pou editing
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   889
            self.CurrentElementEditing = self.ElementsOpened.index(name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   890
            return self.CurrentElementEditing
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   891
        return None
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   892
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   893
    # Change current pou editing for transition given by pou and transition names
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   894
    def ChangePouTransitionEditing(self, pou, transition):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   895
        return self.ChangeElementEditing(self.ComputePouTransitionName(pou, transition))
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   896
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   897
    # Change current pou editing for action given by pou and action names
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   898
    def ChangePouActionEditing(self, pou, action):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   899
        return self.ChangeElementEditing(self.ComputePouActionName(pou, action))
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   900
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   901
    # Change current pou editing for action given by configuration and resource names
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   902
    def ChangeConfigurationResourceEditing(self, config, resource):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   903
        return self.ChangeElementEditing(self.ComputeConfigurationResourceName(config, resource))
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   904
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   905
#-------------------------------------------------------------------------------
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   906
#                       Project opened Pous management functions
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   907
#-------------------------------------------------------------------------------
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   908
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   909
    # Return current pou editing
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   910
    def GetCurrentElementEditing(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   911
        # Verify that there's one editing and return it
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   912
        if self.CurrentElementEditing != None:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   913
            name = self.ElementsOpened[self.CurrentElementEditing]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   914
            words = name.split("::")
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   915
            if len(words) == 1:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   916
                return self.Project.getPou(name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   917
            else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   918
                if words[0] in ['T', 'A']:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   919
                    pou = self.Project.getPou(words[1])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   920
                    if words[0] == 'T':
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   921
                        return pou.getTransition(words[2])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   922
                    elif words[0] == 'A':
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   923
                        return pou.getAction(words[2])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   924
                elif words[0] == 'R':
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   925
                    result = self.Project.getConfigurationResource(words[1], words[2])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   926
                    return result
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   927
        return None
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   928
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   929
    # Return current pou editing name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   930
    def GetCurrentElementEditingName(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   931
        # Verify that there's one editing and return its name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   932
        if self.CurrentElementEditing != None:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   933
            name = self.ElementsOpened[self.CurrentElementEditing]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   934
            words = name.split("::")
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   935
            if len(words) == 1:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   936
                return name
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   937
            else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   938
                return words[2]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   939
        return None
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   940
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   941
    # Replace the index of current pou editing by the one given
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   942
    def RefreshCurrentElementEditing(self, index):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   943
        self.CurrentElementEditing = index
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   944
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   945
    # Return language in which current pou editing is written
13
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   946
    def GetCurrentElementEditingType(self):
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   947
        if self.CurrentElementEditing != None:
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   948
            name = self.ElementsOpened[self.CurrentElementEditing]
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   949
            words = name.split("::")
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   950
            if len(words) == 1:
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   951
                return self.GetPouType(name)
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   952
            else:
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   953
                return self.GetPouType(words[1])
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   954
        return None
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   955
69075340d6a9 Adding support for forbidding insertion of function block into function
lbessard
parents: 6
diff changeset
   956
    # Return language in which current pou editing is written
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   957
    def GetCurrentElementEditingBodyType(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   958
        if self.CurrentElementEditing != None:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   959
            name = self.ElementsOpened[self.CurrentElementEditing]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   960
            words = name.split("::")
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   961
            if len(words) == 1:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   962
                return self.GetPouBodyType(name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   963
            else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   964
                if words[0] == 'T':
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   965
                    return self.GetTransitionBodyType(words[1], words[2])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   966
                elif words[0] == 'A':
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   967
                    return self.GetActionBodyType(words[1], words[2])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   968
        return None
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   969
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   970
    # Return the variables of the current pou editing
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   971
    def GetCurrentElementEditingInterfaceVars(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   972
        if self.CurrentElementEditing != None:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   973
            current_name = self.ElementsOpened[self.CurrentElementEditing]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   974
            words = current_name.split("::")
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   975
            if len(words) == 1:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   976
                pou = self.Project.getPou(current_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   977
                return self.GetPouInterfaceVars(pou)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   978
            else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   979
                pou = self.Project.getPou(words[1])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   980
                return self.GetPouInterfaceVars(pou)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   981
        return []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   982
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   983
    # Return the return type of the current pou editing
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   984
    def GetCurrentElementEditingInterfaceReturnType(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   985
        if self.CurrentElementEditing != None:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   986
            current_name = self.ElementsOpened[self.CurrentElementEditing]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   987
            words = current_name.split("::")
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   988
            if len(words) == 1:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   989
                pou = self.Project.getPou(current_name)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   990
                return self.GetPouInterfaceReturnType(pou)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   991
            elif words[0] == 'T':
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   992
                return "BOOL"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   993
        return None
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   994
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   995
    # Change the text of the current pou editing
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   996
    def SetCurrentElementEditingText(self, text):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   997
        if self.CurrentElementEditing != None:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   998
            self.GetCurrentElementEditing().setText(text)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
   999
            self.RefreshPouUsingTree()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1000
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1001
    # Return the current pou editing text
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1002
    def GetCurrentElementEditingText(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1003
        if self.CurrentElementEditing != None:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1004
            return self.GetCurrentElementEditing().getText()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1005
        return ""
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1006
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1007
    # Return the current pou editing transitions
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1008
    def GetCurrentElementEditingTransitions(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1009
        if self.CurrentElementEditing != None:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1010
            pou = self.GetCurrentElementEditing()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1011
            if pou.getBodyType() == "SFC":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1012
                transitions = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1013
                for transition in pou.getTransitionList():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1014
                    transitions.append(transition.getName())
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1015
                return transitions
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1016
        return []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1017
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1018
    # Return the current pou editing transitions
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1019
    def GetCurrentElementEditingActions(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1020
        if self.CurrentElementEditing != None:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1021
            pou = self.GetCurrentElementEditing()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1022
            if pou.getBodyType() == "SFC":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1023
                actions = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1024
                for action in pou.getActionList():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1025
                    actions.append(action.getName())
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1026
                return actions
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1027
        return []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1028
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1029
    # Return the current pou editing informations
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1030
    def GetCurrentElementEditingInstanceInfos(self, id = None, exclude = []):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1031
        infos = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1032
        # if id is defined
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1033
        if id != None:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1034
            instance = self.GetCurrentElementEditing().getInstance(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1035
        else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1036
            instance = self.GetCurrentElementEditing().getRandomInstance(exclude)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1037
        if instance:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1038
            if id != None:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1039
                infos["id"] = id
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1040
            else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1041
                infos["id"] = instance.getLocalId() 
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1042
            infos["x"] = instance.getX()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1043
            infos["y"] = instance.getY()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1044
            infos["height"] = instance.getHeight()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1045
            infos["width"] = instance.getWidth()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1046
            if isinstance(instance, plcopen.block):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1047
                infos["name"] = instance.getInstanceName()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1048
                infos["type"] = instance.getTypeName()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1049
                infos["connectors"] = {"inputs":[],"outputs":[]}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1050
                for variable in instance.inputVariables.getVariable():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1051
                    connector = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1052
                    connector["position"] = variable.connectionPointIn.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1053
                    connector["negated"] = variable.getNegated()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1054
                    connector["edge"] = variable.getConnectorEdge()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1055
                    connector["links"] = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1056
                    connections = variable.connectionPointIn.getConnections()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1057
                    if connections:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1058
                        for link in connections:
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1059
                            dic = {"refLocalId":link.getRefLocalId(),"points":link.getPoints(),"formalParameter":link.getFormalParameter()}
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1060
                            connector["links"].append(dic)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1061
                    infos["connectors"]["inputs"].append(connector)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1062
                for variable in instance.outputVariables.getVariable():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1063
                    connector = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1064
                    connector["position"] = variable.connectionPointOut.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1065
                    connector["negated"] = variable.getNegated()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1066
                    connector["edge"] = variable.getConnectorEdge()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1067
                    infos["connectors"]["outputs"].append(connector)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1068
            elif isinstance(instance, plcopen.inVariable):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1069
                infos["name"] = instance.getExpression()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1070
                infos["value_type"] = self.GetPouVarValueType(self.GetCurrentElementEditing(), infos["name"])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1071
                infos["type"] = "input"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1072
                infos["connector"] = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1073
                infos["connector"]["position"] = instance.connectionPointOut.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1074
                infos["connector"]["negated"] = instance.getNegated()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1075
                infos["connector"]["edge"] = instance.getConnectorEdge()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1076
            elif isinstance(instance, plcopen.outVariable):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1077
                infos["name"] = instance.getExpression()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1078
                infos["value_type"] = self.GetPouVarValueType(self.GetCurrentElementEditing(), infos["name"])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1079
                infos["type"] = "output"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1080
                infos["connector"] = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1081
                infos["connector"]["position"] = instance.connectionPointIn.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1082
                infos["connector"]["negated"] = instance.getNegated()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1083
                infos["connector"]["edge"] = instance.getConnectorEdge()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1084
                infos["connector"]["links"] = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1085
                connections = instance.connectionPointIn.getConnections()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1086
                if connections:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1087
                    for link in connections:
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1088
                        dic = {"refLocalId":link.getRefLocalId(),"points":link.getPoints(),"formalParameter":link.getFormalParameter()}
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1089
                        infos["connector"]["links"].append(dic)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1090
            elif isinstance(instance, plcopen.inOutVariable):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1091
                infos["name"] = instance.getExpression()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1092
                infos["value_type"] = self.GetPouVarValueType(self.GetCurrentElementEditing(), infos["name"])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1093
                infos["type"] = "inout"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1094
                infos["connectors"] = {"input":{},"output":{}}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1095
                infos["connectors"]["output"]["position"] = instance.connectionPointOut.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1096
                infos["connectors"]["output"]["negated"] = instance.getNegatedOut()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1097
                infos["connectors"]["output"]["edge"] = instance.getOutputEdge()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1098
                infos["connectors"]["input"]["position"] = instance.connectionPointIn.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1099
                infos["connectors"]["input"]["negated"] = instance.getNegatedIn()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1100
                infos["connectors"]["input"]["edge"] = instance.getInputEdge()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1101
                infos["connectors"]["input"]["links"] = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1102
                connections = instance.connectionPointIn.getConnections()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1103
                if connections:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1104
                    for link in connections:
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1105
                        dic = {"refLocalId":link.getRefLocalId(),"points":link.getPoints(),"formalParameter":link.getFormalParameter()}
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1106
                        infos["connectors"]["input"]["links"].append(dic)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1107
            elif isinstance(instance, plcopen.continuation):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1108
                infos["name"] = instance.getName()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1109
                infos["value_type"] = self.GetPouVarValueType(self.GetCurrentElementEditing(), infos["name"])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1110
                infos["type"] = "continuation"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1111
                infos["connector"] = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1112
                infos["connector"]["position"] = instance.connectionPointOut.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1113
            elif isinstance(instance, plcopen.connector):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1114
                infos["name"] = instance.getName()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1115
                infos["value_type"] = self.GetPouVarValueType(self.GetCurrentElementEditing(), infos["name"])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1116
                infos["type"] = "connection"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1117
                infos["connector"] = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1118
                infos["connector"]["position"] = instance.connectionPointIn.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1119
                infos["connector"]["links"] = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1120
                connections = instance.connectionPointIn.getConnections()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1121
                if connections:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1122
                    for link in connections:
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1123
                        dic = {"refLocalId":link.getRefLocalId(),"points":link.getPoints(),"formalParameter":link.getFormalParameter()}
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1124
                        infos["connector"]["links"].append(dic)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1125
            elif isinstance(instance, plcopen.comment):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1126
                infos["type"] = "comment"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1127
                infos["content"] = instance.getContentText()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1128
            elif isinstance(instance, plcopen.leftPowerRail):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1129
                infos["type"] = "leftPowerRail"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1130
                infos["connectors"] = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1131
                for connection in instance.getConnectionPointOut():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1132
                    connector = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1133
                    connector["position"] = connection.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1134
                    infos["connectors"].append(connector)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1135
            elif isinstance(instance, plcopen.rightPowerRail):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1136
                infos["type"] = "rightPowerRail"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1137
                infos["connectors"] = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1138
                for connection in instance.getConnectionPointIn():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1139
                    connector = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1140
                    connector["position"] = connection.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1141
                    connector["links"] = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1142
                    for link in connection.getConnections():
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1143
                        dic = {"refLocalId":link.getRefLocalId(),"points":link.getPoints(),"formalParameter":link.getFormalParameter()}
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1144
                        connector["links"].append(dic)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1145
                    infos["connectors"].append(connector)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1146
            elif isinstance(instance, plcopen.contact):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1147
                infos["type"] = "contact"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1148
                infos["name"] = instance.getVariable()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1149
                infos["negated"] = instance.getNegated()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1150
                infos["edge"] = instance.getContactEdge()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1151
                infos["connectors"] = {"input":{},"output":{}}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1152
                infos["connectors"]["input"]["position"] = instance.connectionPointIn.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1153
                infos["connectors"]["input"]["links"] = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1154
                connections = instance.connectionPointIn.getConnections()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1155
                if connections:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1156
                    for link in connections:
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1157
                        dic = {"refLocalId":link.getRefLocalId(),"points":link.getPoints(),"formalParameter":link.getFormalParameter()}
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1158
                        infos["connectors"]["input"]["links"].append(dic)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1159
                infos["connectors"]["output"]["position"] = instance.connectionPointOut.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1160
            elif isinstance(instance, plcopen.coil):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1161
                infos["type"] = "coil"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1162
                infos["name"] = instance.getVariable()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1163
                infos["negated"] = instance.getNegated()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1164
                infos["storage"] = instance.getCoilStorage()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1165
                infos["connectors"] = {"input":{},"output":{}}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1166
                infos["connectors"]["input"]["position"] = instance.connectionPointIn.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1167
                infos["connectors"]["input"]["links"] = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1168
                connections = instance.connectionPointIn.getConnections()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1169
                if connections:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1170
                    for link in connections:
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1171
                        dic = {"refLocalId":link.getRefLocalId(),"points":link.getPoints(),"formalParameter":link.getFormalParameter()}
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1172
                        infos["connectors"]["input"]["links"].append(dic)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1173
                infos["connectors"]["output"]["position"] = instance.connectionPointOut.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1174
            elif isinstance(instance, plcopen.step):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1175
                infos["type"] = "step"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1176
                infos["name"] = instance.getName()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1177
                infos["initial"] = instance.getInitialStep()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1178
                infos["connectors"] = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1179
                if instance.connectionPointIn:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1180
                    infos["connectors"]["input"] = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1181
                    infos["connectors"]["input"]["position"] = instance.connectionPointIn.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1182
                    infos["connectors"]["input"]["links"] = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1183
                    connections = instance.connectionPointIn.getConnections()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1184
                    if connections:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1185
                        for link in connections:
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1186
                            dic = {"refLocalId":link.getRefLocalId(),"points":link.getPoints(),"formalParameter":link.getFormalParameter()}
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1187
                            infos["connectors"]["input"]["links"].append(dic)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1188
                if instance.connectionPointOut:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1189
                    infos["connectors"]["output"] = {"position" : instance.connectionPointOut.getRelPosition()}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1190
                if instance.connectionPointOutAction:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1191
                    infos["connectors"]["action"] = {"position" : instance.connectionPointOutAction.getRelPosition()}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1192
            elif isinstance(instance, plcopen.transition):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1193
                infos["type"] = "transition"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1194
                condition = instance.getConditionContent()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1195
                infos["condition_type"] = condition["type"]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1196
                infos["condition"] = condition["value"]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1197
                infos["connectors"] = {"input":{},"output":{}}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1198
                infos["connectors"]["input"]["position"] = instance.connectionPointIn.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1199
                infos["connectors"]["input"]["links"] = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1200
                connections = instance.connectionPointIn.getConnections()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1201
                if connections:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1202
                    for link in connections:
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1203
                        dic = {"refLocalId":link.getRefLocalId(),"points":link.getPoints(),"formalParameter":link.getFormalParameter()}
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1204
                        infos["connectors"]["input"]["links"].append(dic)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1205
                infos["connectors"]["output"]["position"] = instance.connectionPointOut.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1206
            elif isinstance(instance, (plcopen.selectionDivergence, plcopen.simultaneousDivergence)):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1207
                if isinstance(instance, plcopen.selectionDivergence):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1208
                    infos["type"] = "selectionDivergence"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1209
                else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1210
                    infos["type"] = "simultaneousDivergence"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1211
                infos["connectors"] = {"inputs":[],"outputs":[]}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1212
                connector = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1213
                connector["position"] = instance.connectionPointIn.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1214
                connector["links"] = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1215
                connections = instance.connectionPointIn.getConnections()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1216
                if connections:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1217
                    for link in connections:
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1218
                        dic = {"refLocalId":link.getRefLocalId(),"points":link.getPoints(),"formalParameter":link.getFormalParameter()}
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1219
                        connector["links"].append(dic)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1220
                infos["connectors"]["inputs"].append(connector)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1221
                for sequence in instance.getConnectionPointOut():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1222
                    connector = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1223
                    connector["position"] = sequence.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1224
                    infos["connectors"]["outputs"].append(connector)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1225
            elif isinstance(instance, (plcopen.selectionConvergence, plcopen.simultaneousConvergence)):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1226
                if isinstance(instance, plcopen.selectionConvergence):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1227
                    infos["type"] = "selectionConvergence"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1228
                else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1229
                    infos["type"] = "simultaneousConvergence"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1230
                infos["connectors"] = {"inputs":[],"outputs":[]}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1231
                for sequence in instance.getConnectionPointIn():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1232
                    connector = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1233
                    connector["position"] = sequence.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1234
                    connector["links"] = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1235
                    connections = sequence.getConnections()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1236
                    if connections:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1237
                        for link in connections:
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1238
                            dic = {"refLocalId":link.getRefLocalId(),"points":link.getPoints(),"formalParameter":link.getFormalParameter()}
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1239
                            connector["links"].append(dic)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1240
                    infos["connectors"]["inputs"].append(connector)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1241
                connector = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1242
                connector["position"] = instance.connectionPointOut.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1243
                infos["connectors"]["outputs"].append(connector)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1244
            elif isinstance(instance, plcopen.jumpStep):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1245
                infos["type"] = "jump"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1246
                infos["target"] = instance.getTargetName()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1247
                infos["connector"] = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1248
                infos["connector"]["position"] = instance.connectionPointIn.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1249
                infos["connector"]["links"] = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1250
                connections = instance.connectionPointIn.getConnections()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1251
                if connections:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1252
                    for link in connections:
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1253
                        dic = {"refLocalId":link.getRefLocalId(),"points":link.getPoints(),"formalParameter":link.getFormalParameter()}
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1254
                        infos["connector"]["links"].append(dic)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1255
            elif isinstance(instance, plcopen.actionBlock):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1256
                infos["type"] = "actionBlock"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1257
                infos["actions"] = instance.getActions()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1258
                infos["connector"] = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1259
                infos["connector"]["position"] = instance.connectionPointIn.getRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1260
                infos["connector"]["links"] = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1261
                connections = instance.connectionPointIn.getConnections()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1262
                if connections:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1263
                    for link in connections:
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1264
                        dic = {"refLocalId":link.getRefLocalId(),"points":link.getPoints(),"formalParameter":link.getFormalParameter()}
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1265
                        infos["connector"]["links"].append(dic)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1266
            return infos
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1267
        return False
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1268
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1269
    # Return the variable type of the given pou
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1270
    def GetPouVarValueType(self, pou, varname):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1271
        for type, varlist in pou.getVars():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1272
            for var in varlist.getVariable():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1273
                if var.getName() == varname:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1274
                    return var.getType()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1275
        return ""
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1276
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1277
    def SetConnectionWires(self, connection, connector):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1278
        wires = connector.GetWires()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1279
        idx = 0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1280
        for wire, handle in wires:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1281
            points = wire.GetPoints(handle != 0)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1282
            if handle == 0:
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1283
                result = wire.GetConnectedInfos(-1)
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1284
            else:
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1285
                result = wire.GetConnectedInfos(0)
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1286
            if result != None:
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1287
                refLocalId, formalParameter = result
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1288
                connection.addConnection()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1289
                connection.setConnectionId(idx, refLocalId)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1290
                connection.setConnectionPoints(idx, points)
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1291
                if formalParameter != "":
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1292
                    connection.setConnectionParameter(idx, formalParameter)
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1293
                else:
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1294
                    connection.setConnectionParameter(idx, None)
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1295
                idx += 1
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1296
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1297
    def AddCurrentElementEditingBlock(self, id):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1298
        block = plcopen.block()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1299
        block.setLocalId(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1300
        self.GetCurrentElementEditing().addInstance("block", block)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1301
        self.RefreshPouUsingTree()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1302
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1303
    def SetCurrentElementEditingBlockInfos(self, id, infos):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1304
        block = self.GetCurrentElementEditing().getInstance(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1305
        for param, value in infos.items():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1306
            if param == "name":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1307
                block.setInstanceName(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1308
            elif param == "type":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1309
                block.setTypeName(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1310
            elif param == "height":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1311
                block.setHeight(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1312
            elif param == "width":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1313
                block.setWidth(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1314
            elif param == "x":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1315
                block.setX(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1316
            elif param == "y":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1317
                block.setY(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1318
            elif param == "connectors":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1319
                block.inputVariables.setVariable([])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1320
                block.outputVariables.setVariable([])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1321
                for connector in value["inputs"]:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1322
                    variable = plcopen.inputVariables_variable()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1323
                    variable.setFormalParameter(connector.GetName())
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1324
                    if connector.IsNegated():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1325
                        variable.setNegated(True)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1326
                    if connector.GetEdge() != "none":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1327
                        variable.setConnectorEdge(connector.GetEdge())
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1328
                    position = connector.GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1329
                    variable.connectionPointIn.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1330
                    self.SetConnectionWires(variable.connectionPointIn, connector)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1331
                    block.inputVariables.appendVariable(variable)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1332
                for connector in value["outputs"]:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1333
                    variable = plcopen.outputVariables_variable()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1334
                    variable.setFormalParameter(connector.GetName())
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1335
                    if connector.IsNegated():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1336
                        variable.setNegated(True)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1337
                    if connector.GetEdge() != "none":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1338
                        variable.setConnectorEdge(connector.GetEdge())
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1339
                    position = connector.GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1340
                    variable.addConnectionPointOut()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1341
                    variable.connectionPointOut.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1342
                    block.outputVariables.appendVariable(variable)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1343
        self.RefreshPouUsingTree()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1344
        
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1345
    def AddCurrentElementEditingVariable(self, id, type):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1346
        if type == INPUT:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1347
            name = "inVariable"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1348
            variable = plcopen.inVariable()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1349
        elif type == OUTPUT:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1350
            name = "outVariable"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1351
            variable = plcopen.outVariable()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1352
        elif type == INOUT:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1353
            name = "inOutVariable"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1354
            variable = plcopen.inOutVariable()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1355
        variable.setLocalId(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1356
        self.GetCurrentElementEditing().addInstance(name, variable)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1357
        
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1358
    def SetCurrentElementEditingVariableInfos(self, id, infos):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1359
        variable = self.GetCurrentElementEditing().getInstance(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1360
        for param, value in infos.items():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1361
            if param == "name":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1362
                variable.setExpression(value)    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1363
            elif param == "height":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1364
                variable.setHeight(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1365
            elif param == "width":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1366
                variable.setWidth(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1367
            elif param == "x":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1368
                variable.setX(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1369
            elif param == "y":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1370
                variable.setY(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1371
            elif param == "connectors":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1372
                if isinstance(variable, plcopen.inVariable):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1373
                    if value["output"].IsNegated():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1374
                        variable.setNegated(True)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1375
                    if value["output"].GetEdge() != "none":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1376
                        variable.setConnectorEdge(value["output"].GetEdge())
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1377
                    position = value["output"].GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1378
                    variable.addConnectionPointOut()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1379
                    variable.connectionPointOut.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1380
                elif isinstance(variable, plcopen.outVariable):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1381
                    if value["input"].IsNegated():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1382
                        variable.setNegated(True)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1383
                    if value["input"].GetEdge() != "none":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1384
                        variable.setConnectorEdge(value["input"].GetEdge())
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1385
                    position = value["input"].GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1386
                    variable.addConnectionPointIn()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1387
                    variable.connectionPointIn.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1388
                    self.SetConnectionWires(variable.connectionPointIn, value["input"])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1389
                elif isinstance(variable, plcopen.inOutVariable):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1390
                    if value["input"].IsNegated():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1391
                        variable.setNegatedIn(True)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1392
                    if value["input"].GetEdge() != "none":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1393
                        variable.setInputEdge(value["input"].GetEdge())
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1394
                    if value["output"].IsNegated():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1395
                        variable.setNegatedOut(True)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1396
                    if value["output"].GetEdge() != "none":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1397
                        variable.setOutputEdge(value["output"].GetEdge())
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1398
                    position = value["output"].GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1399
                    variable.addConnectionPointOut()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1400
                    variable.connectionPointOut.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1401
                    position = value["input"].GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1402
                    variable.addConnectionPointIn()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1403
                    variable.connectionPointIn.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1404
                    self.SetConnectionWires(variable.connectionPointIn, value["input"])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1405
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1406
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1407
    def AddCurrentElementEditingConnection(self, id, type):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1408
        if type == CONNECTOR:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1409
            name = "connector"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1410
            connection = plcopen.connector()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1411
        elif type == CONTINUATION:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1412
            name = "continuation"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1413
            connection = plcopen.continuation()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1414
        connection.setLocalId(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1415
        self.GetCurrentElementEditing().addInstance(name, connection)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1416
        
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1417
    def SetCurrentElementEditingConnectionInfos(self, id, infos):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1418
        connection = self.GetCurrentElementEditing().getInstance(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1419
        for param, value in infos.items():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1420
            if param == "name":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1421
                connection.setName(value)    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1422
            elif param == "height":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1423
                connection.setHeight(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1424
            elif param == "width":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1425
                connection.setWidth(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1426
            elif param == "x":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1427
                connection.setX(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1428
            elif param == "y":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1429
                connection.setY(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1430
            elif param == "connector":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1431
                position = value.GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1432
                if isinstance(connection, plcopen.continuation):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1433
                    connection.addConnectionPointOut()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1434
                    connection.connectionPointOut.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1435
                elif isinstance(connection, plcopen.connector):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1436
                    connection.addConnectionPointIn()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1437
                    connection.connectionPointIn.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1438
                    self.SetConnectionWires(connection.connectionPointIn, value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1439
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1440
    def AddCurrentElementEditingComment(self, id):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1441
        comment = plcopen.comment()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1442
        comment.setLocalId(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1443
        self.GetCurrentElementEditing().addInstance("comment", comment)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1444
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1445
    def SetCurrentElementEditingCommentInfos(self, id, infos):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1446
        comment = self.GetCurrentElementEditing().getInstance(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1447
        for param, value in infos.items():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1448
            if param == "content":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1449
                comment.setContentText(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1450
            elif param == "height":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1451
                comment.setHeight(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1452
            elif param == "width":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1453
                comment.setWidth(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1454
            elif param == "x":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1455
                comment.setX(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1456
            elif param == "y":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1457
                comment.setY(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1458
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1459
    def AddCurrentElementEditingPowerRail(self, id, type):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1460
        if type == LEFTRAIL:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1461
            name = "leftPowerRail"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1462
            powerrail = plcopen.leftPowerRail()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1463
        elif type == RIGHTRAIL:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1464
            name = "rightPowerRail"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1465
            powerrail = plcopen.rightPowerRail()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1466
        powerrail.setLocalId(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1467
        self.GetCurrentElementEditing().addInstance(name, powerrail)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1468
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1469
    def SetCurrentElementEditingPowerRailInfos(self, id, infos):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1470
        powerrail = self.GetCurrentElementEditing().getInstance(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1471
        for param, value in infos.items():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1472
            if param == "height":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1473
                powerrail.setHeight(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1474
            elif param == "width":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1475
                powerrail.setWidth(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1476
            elif param == "x":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1477
                powerrail.setX(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1478
            elif param == "y":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1479
                powerrail.setY(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1480
            elif param == "connectors":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1481
                if isinstance(powerrail, plcopen.leftPowerRail):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1482
                    powerrail.setConnectionPointOut([])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1483
                    for connector in value:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1484
                        position = connector.GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1485
                        connection = plcopen.leftPowerRail_connectionPointOut()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1486
                        connection.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1487
                        powerrail.connectionPointOut.append(connection)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1488
                elif isinstance(powerrail, plcopen.rightPowerRail):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1489
                    powerrail.setConnectionPointIn([])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1490
                    for connector in value:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1491
                        position = connector.GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1492
                        connection = plcopen.connectionPointIn()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1493
                        connection.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1494
                        self.SetConnectionWires(connection, connector)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1495
                        powerrail.connectionPointIn.append(connection)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1496
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1497
    def AddCurrentElementEditingContact(self, id):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1498
        contact = plcopen.contact()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1499
        contact.setLocalId(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1500
        self.GetCurrentElementEditing().addInstance("contact", contact)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1501
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1502
    def SetCurrentElementEditingContactInfos(self, id, infos):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1503
        contact = self.GetCurrentElementEditing().getInstance(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1504
        for param, value in infos.items():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1505
            if param == "name":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1506
                contact.setVariable(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1507
            elif param == "type":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1508
                if value == CONTACT_NORMAL:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1509
                    contact.setNegated(False)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1510
                    contact.setContactEdge("none")
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1511
                elif value == CONTACT_REVERSE:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1512
                    contact.setNegated(True)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1513
                    contact.setContactEdge("none")
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1514
                elif value == CONTACT_RISING:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1515
                    contact.setNegated(False)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1516
                    contact.setContactEdge("rising")
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1517
                elif value == CONTACT_FALLING:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1518
                    contact.setNegated(False)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1519
                    contact.setContactEdge("falling")
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1520
            elif param == "height":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1521
                contact.setHeight(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1522
            elif param == "width":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1523
                contact.setWidth(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1524
            elif param == "x":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1525
                contact.setX(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1526
            elif param == "y":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1527
                contact.setY(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1528
            elif param == "connectors":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1529
                input_connector = value["input"]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1530
                position = input_connector.GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1531
                contact.addConnectionPointIn()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1532
                contact.connectionPointIn.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1533
                self.SetConnectionWires(contact.connectionPointIn, input_connector)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1534
                output_connector = value["output"]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1535
                position = output_connector.GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1536
                contact.addConnectionPointOut()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1537
                contact.connectionPointOut.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1538
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1539
    def AddCurrentElementEditingCoil(self, id):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1540
        coil = plcopen.coil()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1541
        coil.setLocalId(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1542
        self.GetCurrentElementEditing().addInstance("coil", coil)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1543
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1544
    def SetCurrentElementEditingCoilInfos(self, id, infos):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1545
        coil = self.GetCurrentElementEditing().getInstance(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1546
        for param, value in infos.items():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1547
            if param == "name":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1548
                coil.setVariable(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1549
            elif param == "type":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1550
                if value == COIL_NORMAL:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1551
                    coil.setNegated(False)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1552
                    coil.setCoilStorage("none")
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1553
                elif value == COIL_REVERSE:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1554
                    coil.setNegated(True)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1555
                    coil.setCoilStorage("none")
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1556
                elif value == COIL_SET:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1557
                    coil.setNegated(False)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1558
                    coil.setCoilStorage("set")
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1559
                elif value == COIL_RESET:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1560
                    coil.setNegated(False)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1561
                    coil.setCoilStorage("reset")
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1562
            elif param == "height":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1563
                coil.setHeight(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1564
            elif param == "width":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1565
                coil.setWidth(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1566
            elif param == "x":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1567
                coil.setX(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1568
            elif param == "y":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1569
                coil.setY(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1570
            elif param == "connectors":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1571
                input_connector = value["input"]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1572
                position = input_connector.GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1573
                coil.addConnectionPointIn()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1574
                coil.connectionPointIn.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1575
                self.SetConnectionWires(coil.connectionPointIn, input_connector)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1576
                output_connector = value["output"]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1577
                position = output_connector.GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1578
                coil.addConnectionPointOut()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1579
                coil.connectionPointOut.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1580
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1581
    def AddCurrentElementEditingStep(self, id):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1582
        step = plcopen.step()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1583
        step.setLocalId(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1584
        self.GetCurrentElementEditing().addInstance("step", step)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1585
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1586
    def SetCurrentElementEditingStepInfos(self, id, infos):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1587
        step = self.GetCurrentElementEditing().getInstance(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1588
        for param, value in infos.items():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1589
            if param == "name":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1590
                step.setName(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1591
            elif param == "initial":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1592
                step.setInitialStep(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1593
            elif param == "height":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1594
                step.setHeight(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1595
            elif param == "width":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1596
                step.setWidth(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1597
            elif param == "x":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1598
                step.setX(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1599
            elif param == "y":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1600
                step.setY(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1601
            elif param == "connectors":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1602
                input_connector = value["input"]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1603
                if input_connector:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1604
                    position = input_connector.GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1605
                    step.addConnectionPointIn()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1606
                    step.connectionPointIn.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1607
                    self.SetConnectionWires(step.connectionPointIn, input_connector)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1608
                else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1609
                    step.deleteConnectionPointIn()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1610
                output_connector = value["output"]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1611
                if output_connector:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1612
                    position = output_connector.GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1613
                    step.addConnectionPointOut()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1614
                    step.connectionPointOut.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1615
                else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1616
                    step.deleteConnectionPointOut()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1617
                action_connector = value["action"]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1618
                if action_connector:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1619
                    position = action_connector.GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1620
                    step.addConnectionPointOutAction()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1621
                    step.connectionPointOutAction.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1622
                else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1623
                    step.deleteConnectionPointOutAction()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1624
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1625
    def AddCurrentElementEditingTransition(self, id):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1626
        transition = plcopen.transition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1627
        transition.setLocalId(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1628
        self.GetCurrentElementEditing().addInstance("transition", transition)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1629
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1630
    def SetCurrentElementEditingTransitionInfos(self, id, infos):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1631
        transition = self.GetCurrentElementEditing().getInstance(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1632
        for param, value in infos.items():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1633
            if param == "type" and "condition" in infos:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1634
                transition.setConditionContent(value, infos["condition"])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1635
            elif param == "height":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1636
                transition.setHeight(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1637
            elif param == "width":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1638
                transition.setWidth(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1639
            elif param == "x":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1640
                transition.setX(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1641
            elif param == "y":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1642
                transition.setY(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1643
            elif param == "connectors":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1644
                input_connector = value["input"]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1645
                position = input_connector.GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1646
                transition.addConnectionPointIn()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1647
                transition.connectionPointIn.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1648
                self.SetConnectionWires(transition.connectionPointIn, input_connector)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1649
                output_connector = value["output"]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1650
                position = output_connector.GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1651
                transition.addConnectionPointOut()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1652
                transition.connectionPointOut.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1653
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1654
    def AddCurrentElementEditingDivergence(self, id, type):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1655
        if type == SELECTION_DIVERGENCE:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1656
            name = "selectionDivergence"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1657
            divergence = plcopen.selectionDivergence()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1658
        elif type == SELECTION_CONVERGENCE:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1659
            name = "selectionConvergence"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1660
            divergence = plcopen.selectionConvergence()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1661
        elif type == SIMULTANEOUS_DIVERGENCE:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1662
            name = "simultaneousDivergence"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1663
            divergence = plcopen.simultaneousDivergence()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1664
        elif type == SIMULTANEOUS_CONVERGENCE:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1665
            name = "simultaneousConvergence"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1666
            divergence = plcopen.simultaneousConvergence()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1667
        divergence.setLocalId(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1668
        self.GetCurrentElementEditing().addInstance(name, divergence)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1669
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1670
    def SetCurrentElementEditingDivergenceInfos(self, id, infos):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1671
        divergence = self.GetCurrentElementEditing().getInstance(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1672
        for param, value in infos.items():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1673
            if param == "height":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1674
                divergence.setHeight(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1675
            elif param == "width":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1676
                divergence.setWidth(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1677
            elif param == "x":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1678
                divergence.setX(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1679
            elif param == "y":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1680
                divergence.setY(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1681
            elif param == "connectors":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1682
                input_connectors = value["inputs"]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1683
                if isinstance(divergence, (plcopen.selectionDivergence, plcopen.simultaneousDivergence)):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1684
                    position = input_connectors[0].GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1685
                    divergence.addConnectionPointIn()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1686
                    divergence.connectionPointIn.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1687
                    self.SetConnectionWires(divergence.connectionPointIn, input_connectors[0])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1688
                else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1689
                    divergence.setConnectionPointIn([])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1690
                    for input_connector in input_connectors:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1691
                        position = input_connector.GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1692
                        if isinstance(divergence, plcopen.selectionConvergence):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1693
                            connection = plcopen.selectionConvergence_connectionPointIn()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1694
                        else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1695
                            connection = plcopen.connectionPointIn()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1696
                        connection.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1697
                        self.SetConnectionWires(connection, input_connector)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1698
                        divergence.appendConnectionPointIn(connection)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1699
                output_connectors = value["outputs"]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1700
                if isinstance(divergence, (plcopen.selectionConvergence, plcopen.simultaneousConvergence)):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1701
                    position = output_connectors[0].GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1702
                    divergence.addConnectionPointOut()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1703
                    divergence.connectionPointOut.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1704
                else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1705
                    divergence.setConnectionPointOut([])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1706
                    for output_connector in output_connectors:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1707
                        position = output_connector.GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1708
                        if isinstance(divergence, plcopen.selectionDivergence):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1709
                            connection = plcopen.selectionDivergence_connectionPointOut()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1710
                        else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1711
                            connection = plcopen.simultaneousDivergence_connectionPointOut()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1712
                        connection.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1713
                        divergence.appendConnectionPointOut(connection)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1714
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1715
    def AddCurrentElementEditingJump(self, id):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1716
        jump = plcopen.jumpStep()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1717
        jump.setLocalId(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1718
        self.GetCurrentElementEditing().addInstance("jumpStep", jump)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1719
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1720
    def SetCurrentElementEditingJumpInfos(self, id, infos):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1721
        jump = self.GetCurrentElementEditing().getInstance(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1722
        for param, value in infos.items():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1723
            if param == "target":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1724
                jump.setTargetName(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1725
            elif param == "height":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1726
                jump.setHeight(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1727
            elif param == "width":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1728
                jump.setWidth(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1729
            elif param == "x":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1730
                jump.setX(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1731
            elif param == "y":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1732
                jump.setY(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1733
            elif param == "connector":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1734
                position = value.GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1735
                jump.addConnectionPointIn()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1736
                jump.connectionPointIn.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1737
                self.SetConnectionWires(jump.connectionPointIn, value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1738
 
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1739
    def AddCurrentElementEditingActionBlock(self, id):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1740
        actionBlock = plcopen.actionBlock()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1741
        actionBlock.setLocalId(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1742
        self.GetCurrentElementEditing().addInstance("actionBlock", actionBlock)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1743
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1744
    def SetCurrentElementEditingActionBlockInfos(self, id, infos):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1745
        actionBlock = self.GetCurrentElementEditing().getInstance(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1746
        for param, value in infos.items():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1747
            if param == "actions":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1748
                actionBlock.setActions(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1749
            elif param == "height":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1750
                actionBlock.setHeight(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1751
            elif param == "width":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1752
                actionBlock.setWidth(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1753
            elif param == "x":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1754
                actionBlock.setX(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1755
            elif param == "y":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1756
                actionBlock.setY(value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1757
            elif param == "connector":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1758
                position = value.GetRelPosition()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1759
                actionBlock.addConnectionPointIn()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1760
                actionBlock.connectionPointIn.setRelPosition(position.x, position.y)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1761
                self.SetConnectionWires(actionBlock.connectionPointIn, value)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1762
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1763
    def RemoveCurrentElementEditingInstance(self, id):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1764
        self.GetCurrentElementEditing().removeInstance(id)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1765
        self.RefreshPouUsingTree()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1766
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1767
    def GetCurrentResourceEditingVariables(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1768
        varlist = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1769
        name = self.ElementsOpened[self.CurrentElementEditing]
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1770
        words = name.split("::")
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1771
        for var in self.GetConfigurationGlobalVars(words[1]):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1772
            if var["Type"] == "BOOL":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1773
                varlist.append(var["Name"])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1774
        for var in self.GetConfigurationResourceGlobalVars(words[1], words[2]):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1775
            if var["Type"] == "BOOL":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1776
                varlist.append(var["Name"])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1777
        return varlist
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1778
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1779
    def SetCurrentResourceEditingInfos(self, tasks, instances):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1780
        resource = self.GetCurrentElementEditing()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1781
        resource.setTask([])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1782
        resource.setPouInstance([])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1783
        task_list = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1784
        for task in tasks:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1785
            new_task = plcopen.resource_task()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1786
            new_task.setName(task["Name"])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1787
            if task["Single"] != "":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1788
                new_task.setSingle(task["Single"])
24
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
  1789
            result = duration_model.match(task["Interval"]).groups()
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
  1790
            if reduce(lambda x, y: x or y != None, result):
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
  1791
                values = []
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
  1792
                for value in result:
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
  1793
                    if value != None:
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
  1794
                        values.append(int(value))
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
  1795
                    else:
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
  1796
                        values.append(0)
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
  1797
                values[3] = values[3] * 1000
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
  1798
                new_task.setInterval(time(*values))
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1799
            new_task.priority.setValue(int(task["Priority"]))
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1800
            if task["Name"] != "":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1801
                task_list[task["Name"]] = new_task
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1802
            resource.appendTask(new_task)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1803
        for instance in instances:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1804
            new_instance = plcopen.pouInstance()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1805
            new_instance.setName(instance["Name"])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1806
            new_instance.setType(instance["Type"])
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1807
            if instance["Task"] != "":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1808
                task_list[instance["Task"]].appendPouInstance(new_instance)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1809
            else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1810
                resource.appendPouInstance(new_instance)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1811
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1812
    def GetCurrentResourceEditingInfos(self):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1813
        resource = self.GetCurrentElementEditing()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1814
        tasks = resource.getTask()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1815
        instances = resource.getPouInstance()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1816
        tasks_data = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1817
        instances_data = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1818
        for task in tasks:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1819
            new_task = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1820
            new_task["Name"] = task.getName()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1821
            single = task.getSingle()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1822
            if single:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1823
                new_task["Single"] = single
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1824
            else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1825
                new_task["Single"] = ""
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1826
            interval = task.getInterval()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1827
            if interval:
24
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
  1828
                text = ""
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
  1829
                if interval.hour != 0:
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
  1830
                    text += "%dh"%interval.hour
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
  1831
                if interval.minute != 0:
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
  1832
                    text += "%dm"%interval.minute
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
  1833
                if interval.second != 0:
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
  1834
                    text += "%ds"%interval.second
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
  1835
                if interval.microsecond != 0:
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
  1836
                    text += "%dms"%(interval.microsecond / 1000)
364320323b4d Adding support for date and time data types
lbessard
parents: 13
diff changeset
  1837
                new_task["Interval"] = text
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1838
            else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1839
                new_task["Interval"] = ""
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1840
            new_task["Priority"] = str(task.priority.getValue())
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1841
            tasks_data.append(new_task)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1842
            for instance in task.getPouInstance():
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1843
                new_instance = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1844
                new_instance["Name"] = instance.getName()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1845
                new_instance["Type"] = instance.getType()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1846
                new_instance["Task"] = task.getName()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1847
                instances_data.append(new_instance)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1848
        for instance in instances:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1849
            new_instance = {}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1850
            new_instance["Name"] = instance.getName()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1851
            new_instance["Type"] = instance.getType()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1852
            new_instance["Task"] = ""
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1853
            instances_data.append(new_instance)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1854
        return tasks_data, instances_data
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1855
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1856
    def OpenXMLFile(self, filepath):
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1857
        if self.VerifyXML:
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1858
            if sys:
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1859
                sys.stdout = HolePseudoFile()
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1860
            result = pyxsval.parseAndValidate(filepath, os.path.join(sys.path[0], "plcopen/TC6_XML_V10_B.xsd"))
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1861
            if sys:
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1862
                sys.stdout = sys.__stdout__
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1863
            tree = result.getTree()
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1864
        else:
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1865
            xmlfile = open(filepath, 'r')
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1866
            tree = minidom.parse(xmlfile)
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1867
            xmlfile.close()
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1868
        
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1869
        self.Project = plcopen.project()
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1870
        self.Project.loadXMLTree(tree.childNodes[0])
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1871
        self.UndoBuffer = UndoBuffer(self.Copy(self.Project), True)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1872
        self.SetFilePath(filepath)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1873
        self.ElementsOpened = []
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1874
        self.CurrentElementEditing = None
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1875
        self.RefreshPouUsingTree()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1876
        self.RefreshBlockTypes()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1877
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1878
    def SaveXMLFile(self, filepath = None):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1879
        if not filepath and self.FilePath == "":
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1880
            return False
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1881
        else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1882
            text = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1883
            extras = {"xmlns" : "http://www.plcopen.org/xml/tc6.xsd",
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1884
                      "xmlns:xhtml" : "http://www.w3.org/1999/xhtml",
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1885
                      "xmlns:xsi" : "http://www.w3.org/2001/XMLSchema-instance",
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1886
                      "xsi:schemaLocation" : "http://www.plcopen.org/xml/tc6.xsd http://www.plcopen.org/xml/tc6.xsd"}
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1887
            text += self.Project.generateXMLText("project", 0, extras)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1888
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1889
            if self.VerifyXML:
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1890
                if sys:
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1891
                    sys.stdout = HolePseudoFile()
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1892
                pyxsval.parseAndValidateString(text, open(os.path.join(sys.path[0], "plcopen/TC6_XML_V10_B.xsd"),"r").read())
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1893
                if sys:
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1894
                    sys.stdout = sys.__stdout__
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1895
            
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1896
            if filepath:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1897
                xmlfile = open(filepath,"w")
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1898
            else:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1899
                xmlfile = open(self.FilePath,"w")
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1900
            xmlfile.write(text)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1901
            xmlfile.close()
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1902
            #self.ProjectBuffer.CurrentSaved()
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1903
            if filepath:
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1904
                self.SetFilePath(filepath)
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1905
            return True
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1906
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1907
#-------------------------------------------------------------------------------
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1908
#                      Current Buffering Management Functions
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1909
#-------------------------------------------------------------------------------
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1910
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1911
    """
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1912
    Return a copy of the project
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1913
    """
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1914
    def Copy(self, model):
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1915
        return cPickle.loads(cPickle.dumps(model))
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1916
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1917
    def BufferProject(self):
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1918
        self.ProjectBuffer.Buffering(self.Copy(self))
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1919
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1920
    def ProjectIsSaved(self):
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1921
        return self.ProjectBuffer.IsCurrentSaved()
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1922
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1923
    def LoadPrevious(self):
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1924
        self.Project = self.Copy(self.ProjectBuffer.Previous())
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1925
        self.RefreshElementsOpened()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1926
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1927
    def LoadNext(self):
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1928
        self.Project = self.Copy(self.ProjectBuffer.Next())
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1929
        self.RefreshElementsOpened()
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1930
    
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1931
    def GetBufferState(self):
27
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1932
        first = self.ProjectBuffer.IsFirst()
dae55dd9ee14 Current developping version
lbessard
parents: 24
diff changeset
  1933
        last = self.ProjectBuffer.IsLast()
0
b622defdfd98 PLCOpenEditor initial commit. 31/01/07.
etisserant
parents:
diff changeset
  1934
        return not first, not last