--- a/editors/SFCViewer.py Wed Nov 30 14:27:18 2016 +0300
+++ b/editors/SFCViewer.py Thu Dec 01 16:40:49 2016 +0300
@@ -31,55 +31,57 @@
from graphics.GraphicCommons import SELECTION_DIVERGENCE, \
SELECTION_CONVERGENCE, SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE, EAST, NORTH, WEST, SOUTH
-type = [SELECTION_DIVERGENCE, SELECTION_CONVERGENCE, SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]
-divergence = dict(zip(type,["SELECTION_DIVERGENCE", "SELECTION_CONVERGENCE",\
- "SIMULTANEOUS_DIVERGENCE", "SIMULTANEOUS_CONVERGENCE"]))
SFC_Objects = (SFC_Step, SFC_ActionBlock, SFC_Transition, SFC_Divergence, SFC_Jump)
-StandardRules = {
- # The key of this dict is a block that user try to connect,
- # and the value is a list of blocks, that can be connected with the current block.
- "SFC_Step" : ["SFC_ActionBlock",
- "SFC_Transition",
- "SELECTION_DIVERGENCE",
- "SIMULTANEOUS_CONVERGENCE"],
-
- "SFC_ActionBlock" : ["SFC_Step"],
-
- "SFC_Transition" : ["SFC_Step",
- "SELECTION_CONVERGENCE",
- "SIMULTANEOUS_DIVERGENCE",
- "SFC_Jump",
- "FBD_Block",
- "FBD_Variable"
- "LD_Contact",
- "LD_PowerRail",
- "LD_Coil"],
-
- "SELECTION_DIVERGENCE" : ["SFC_Transition"],
-
- "SELECTION_CONVERGENCE" : ["SFC_Step",
- "SFC_Jump"],
-
- "SIMULTANEOUS_DIVERGENCE" : ["SFC_Step"],
-
- "SIMULTANEOUS_CONVERGENCE" : ["SFC_Transition"],
-
- "SFC_Jump" : [],
-
- "FBD_Block" : ["SFC_Transition"],
-
- "FBD_Variable" : ["SFC_Transition"],
-
- "LD_Contact" : ["SFC_Transition"],
-
- "LD_PowerRail" : ["SFC_Transition"],
-
- "LD_Coil" : ["SFC_Transition"]
- }
class SFC_Viewer(Viewer):
+ SFC_StandardRules = {
+ # The key of this dict is a block that user try to connect,
+ # and the value is a list of blocks, that can be connected with the current block
+ # and with directions of connection
+ "SFC_Step": [("SFC_ActionBlock", EAST),
+ ("SFC_Transition", SOUTH),
+ (SELECTION_DIVERGENCE, SOUTH),
+ (SIMULTANEOUS_CONVERGENCE, SOUTH)],
+
+ "SFC_ActionBlock": [("SFC_Step", EAST)],
+
+ "SFC_Transition": [("SFC_Step", SOUTH),
+ (SELECTION_CONVERGENCE, SOUTH),
+ (SIMULTANEOUS_DIVERGENCE, SOUTH),
+ ("SFC_Jump", SOUTH),
+ ("FBD_Block", EAST),
+ ("FBD_Variable", EAST),
+ ("FBD_Connector", EAST),
+ ("LD_Contact", EAST),
+ ("LD_PowerRail", EAST),
+ ("LD_Coil", EAST)],
+
+ SELECTION_DIVERGENCE: [("SFC_Transition", SOUTH)],
+
+ SELECTION_CONVERGENCE: [("SFC_Step", SOUTH),
+ ("SFC_Jump", SOUTH)],
+
+ SIMULTANEOUS_DIVERGENCE: [("SFC_Step", SOUTH)],
+
+ SIMULTANEOUS_CONVERGENCE: [("SFC_Transition", SOUTH)],
+
+ "SFC_Jump": [],
+
+ "FBD_Block": [("SFC_Transition", WEST)],
+
+ "FBD_Variable": [("SFC_Transition", WEST)],
+
+ "FBD_Connector": [("SFC_Transition", WEST)],
+
+ "LD_Contact": [("SFC_Transition", WEST)],
+
+ "LD_PowerRail": [("SFC_Transition", WEST)],
+
+ "LD_Coil": [("SFC_Transition", WEST)]
+ }
+
def __init__(self, parent, tagname, window, controler, debug = False, instancepath = ""):
Viewer.__init__(self, parent, tagname, window, controler, debug, instancepath)
self.CurrentLanguage = "SFC"
@@ -335,20 +337,23 @@
def GetBlockName(self, block):
blockName = block.__class__.__name__
if blockName == "SFC_Divergence":
- blockName = divergence[block.Type]
+ blockName = block.Type
return blockName
# This method check the IEC 61131-3 compatibility between two SFC blocks
def BlockCompatibility(self,startblock = None, endblock = None, direction = None):
if startblock!= None and endblock != None and (isinstance(startblock,SFC_Objects)\
or isinstance(endblock,SFC_Objects)):
- # Full "StandardRules" table would be simmetrical and
+ # Full "SFC_StandardRules" table would be symmetrical and
# to avoid duplicate records and minimize the table only upper part is defined.
if (direction == SOUTH or direction == EAST):
startblock, endblock = endblock, startblock
start = self.GetBlockName(startblock)
end = self.GetBlockName(endblock)
- return end in StandardRules[start]
+ for val in self.SFC_StandardRules[start]:
+ if end in val:
+ return True
+ return False
return True
#-------------------------------------------------------------------------------