Diff of /readme.md [000000] .. [9bc435]  Maximize  Restore

Switch to unified view

a b/readme.md
1
This project is for the ASCII Art Ladder
2
It converts PLCOpenXML files of ladder POUs exported from CODESYS into a beautiful ASCII Art
3
It will initially use:
4
CODESYS Ladder Editor
5
CODESYS PLCOpenXML Export
6
CODESYS Scripting Engine / IronPython
7
Python XML
8
Some new ASCII Ladder format defined in this project
9
10
Step 1: User will create the ladder in CODESYS Ladder Editor.
11
        User will compile the ladder without any errors.
12
13
Step 2: User will export just one single ladder routine to PLCOpenXML
14
15
Step 3: User will run the PLCOpenXMLLadderToASCIILADDER.py script, with the correct arguments
16
17
Step 4: The script will look for a declaration header as plain text and save this
18
19
Step 5: The script will read every subelement of <LD>.  
20
        Ones it can't understand will be put in an exceptions tag
21
22
Step 6: The script will arrange all of the ladder elements into rows and columns.  
23
        This new element array will also list branches in down / in up / out down / out up
24
25
Step 7: The script will write each row and column to a text file in ASCII Art Ladder format
26
27
Step 8: The script will list all truncated names, and complete all truncated EXECUTE blocks
28
29
Example File Output:
30
31
//This is a rung comment
32
(*Also a 
33
  rung comment*)
34
(**Mabe a nicer
35
  * Way to do multiline comments
36
  *)
37
(** supported features:
38
  * 001 ‘Network’
39
  * 002 ‘Box’
40
  * 002 ‘Assignment’
41
  * (003 FB, 003 FN) ‘Box with EN/ENO’
42
  * 002 ‘Input’
43
  * 005 ‘Label’
44
  * 005 ‘Contact’
45
  * 005 ‘Coil’
46
  * 005 Negated Contant
47
  * 006 Branches (note, branches always close!)
48
  * 007 Set coil
49
  * 007 Reset coil
50
  * 008 short circuit evaluation (SCE) (Toggle Parallel Mode) (I dislike this enough I make you use extended ascii)
51
  * 008 Negation (I dislike this enough I make you use extended ascii)
52
  * 009 Jump
53
  * 010 Return
54
  * 011 Network Comment State
55
  * 012 FBD/LD/IL Element ‘Execute’
56
  * 013 Names are too long  (abreviation section)
57
  * I think that's everything actually.  
58
  *)
59
(** Declaration Section:
60
  * Exact copy of the declaration section, with some indentation
61
  * Note any indentation that is the same for each line will be removed
62
  *)
63
{Declaration}
64
  PROGRAM POU
65
  VAR
66
  END_VAR
67
{/Declaration}
68
(** Abbreviation Section:
69
  * Sure it can get confusing.  Maybe later can alter it so not fixed width ladder
70
  * For importing, it is OK to change the abbrevioations however you please
71
  * Rules: Generally if too long:
72
  * take first three letters and last three and add a ~0 through ~9
73
  * If more than 10 have same first three and same last three, the 11th becomes ~~10 
74
  * If there is one or more points in the variable name, shorten the first three and but the point before the ~
75
  *)
76
{Abbreviaitons}
77
  Nam~0GHT := NameEIGHT;
78
  Nam~1GHT := NameONE_HUNDRED_AND_EIGHT;
79
  Nam~2GHT := NameI_CANT_WEIGHT;
80
  F_C~0ate := F_Calculate;
81
  FB.~0ate := FB_Timer.Calculate;
82
{/Abbreviations}
83
(** Execution Section:
84
  * If the execution block is too big to fit,
85
  *   either width ways or column ways, write it's Execution here.
86
  * Note any indentation that is the same for each line will be removed
87
  *)
88
{Executions}
89
  {~1}
90
    thisvariable := actuallyToolong;
91
    REsult := Function();     
92
    //I added a comment       
93
    //If line too long it gets truncated
94
    // >6 line, ~ bottom right
95
    IF TRUE THEN
96
        DoSomethingCool;
97
    END_IF;
98
  {/~1}
99
{/Executions}
100
{Ladder}
101
001     ||.         .         .         .         .         .         ||
102
        ||                                                            ||
103
        ||------------------------------------------------------------||
104
        ||                                                            ||
105
002     ||.         .         .          ________           .         ||
106
        || NameEIGH                     | F_Name |           NameEIGH ||
107
        ||----] [------------------------Input_01|--------------( )---||
108
        ||                     Variable==In_out01|                    ||
109
        ||                              =InOut2  |                    ||
110
        ||                     Variable--Input2  |                    ||
111
        ||                              =InOut3  |                    ||
112
        ||                              |   Out01--Variable           ||
113
        ||                              |   Out02--Variable           ||
114
        ||                              |________|                    ||
115
        ||                                                            ||
116
003     ||.         .         .          ________           .         ||
117
        || NameEIGH  NameEIGH  Instance--FB_Name8|           NameEIGH ||
118
        ||----] [-------] [--------------EN   ENO---------------( )---||
119
        ||                              -Input01 |                    ||
120
        ||                              |   Out01-                    ||
121
        ||                              =In_out01|                    ||
122
        ||                              =Inout2  |                    ||
123
        ||                              |________|                    ||
124
        ||                                                            ||
125
004     ||.         .         .          ________           .         ||
126
        || NameEIGH                     | F_Name |           NameEIGH ||
127
        ||----] [------------------------EN   ENO---------------( )---||
128
        ||                     Variable--Input01 |                    ||
129
        ||                              |   Out01--Variable           ||
130
        ||                     Variable==In_out01|                    ||
131
        ||                     Variable==Inout2  |                    ||
132
        ||                              |________|                    ||
133
        ||                                                            ||
134
005     ||.         .         .         .         .         .         ||
135
myLabel || NameEIGH  NameEIGH                                NameEIGH ||
136
        ||----] [-------]/[-------------------------------------( )---||
137
        ||                                                            ||
138
006     ||.         .         .         .         .         .         ||
139
        || NameEIGH  NameEIGH                                NameEIGH ||
140
        ||+---] [--++---] [------------+------------------------( )---||
141
        |||        ||                  |                              ||
142
        |||        ||         .        |                              ||
143
        |||NameEIGH||NameEIGH  NameEIGH|                              ||
144
        ||+---] [--++---] [-------]/[--+                              ||
145
        ||                                                            ||
146
007     ||.         .         .         .         .         .         ||
147
        ||                               NameEIGH  NameEIGH  NameEIGH ||
148
        ||----------------------------------(R)-------(S)---+---(S)--+||
149
        ||                                                  |        |||
150
        ||                                                  |        |||
151
        ||                                                  |NameEIGH|||
152
        ||                                                  +---(R)--+||
153
        ||                                                            ||
154
008     ||.         .         .         .         .         .         ||
155
        || NameEIGH  ASCII181                                NameEIGH ||
156
        ||----] [---╬---] [--------------------------------╬----( )---||
157
        ||          ║                                      ║          ||
158
        ||          ║         .          ________          ║          ||
159
        ||          ║ASCII206  Instance--FB_Name8|         ║          ||
160
        ||          ╬---] [--------------EN   ENO----------╬          ||
161
        ||                     NegInVarø-Input01 |                    ||
162
        ||                              |   Out01-øASCII155           ||
163
        ||                              =In_out01|                    ||
164
        ||                              =Inout2  |                    ||
165
        ||                              |________|                    ||
166
        ||                                                            ||
167
009     ||.         .         .         .         .         .         ||
168
        ||                                                   myLabel  ||
169
        ||----------------------------------------------------<JUMP>--||
170
        ||                                                            ||
171
010     ||.         .         .         .         .         .         ||
172
        ||                                                            ||
173
        ||---------------------------------------------------<RETURN>-||
174
        ||                                                            ||
175
011     ||##.         .         .         .         .         .         ||
176
        ||## NameEIGH                                                   ||
177
        ||##----] [--------------------------------------------<RETURN>-||
178
        ||##                                                            ||
179
012     ||.         .         . __________________________  .         ||
180
        || NameEIGH            |         Execute    ~1    |           ||
181
        ||----] [---------------EN                     ENO------------||
182
        ||                     |thisvariable := actuallyT~|           ||
183
        ||                     |REsult := Function();     |           ||
184
        ||                     |//I added a comment       |           ||
185
        ||                     |//If line too long it get~|           ||
186
        ||                     |// >6 line, ~ bottom right|           ||
187
        ||                     |IF TRUE THEN              |           ||
188
        ||                     |_________________________~|           ||
189
        ||                                                            ||
190
013     ||.         .         .          ________           .         ||
191
        || FB.~0ate  Nam~1GHT           |F_C~0ate|           Nam~2GHT ||
192
        ||----] [---+---] [--------------EN   ENO----------+----( )---||
193
        ||          |          NegInVarø-Input01 |         |          ||
194
        ||          |                   |   Out01-øASCII155|          ||
195
        ||          |                   =In_out01|         |          ||
196
        ||          |                   =Inout2  |         |          ||
197
        ||          |                   |________|         |          ||
198
        ||          |         .          ________          |          ||
199
        ||          |Nam~0GHT  Instance--FB_Timer|         |          ||
200
        ||          +---] [--------------EN   ENO----------+          ||
201
        ||                     NegInVarø-Input01 |                    ||
202
        ||                              |   Out01-øASCII155           ||
203
        ||                              =In_out01|                    ||
204
        ||                              =Inout2  |                    ||
205
        ||                              |________|                    ||
206
        ||                                                            ||
207
{/Ladder}