File | Date | Author | Commit |
---|---|---|---|
examples | 2020-02-17 | i-campbell | [9bc435] Initial Commit |
.gitignore | 2020-02-17 | i-campbell | [9bc435] Initial Commit |
PlcOpenXmlLadderToAsciiLadder.py | 2020-02-17 | i-campbell | [9bc435] Initial Commit |
UNLICENSE | 2020-02-17 | i-campbell | [9bc435] Initial Commit |
readme.txt | 2020-02-17 | i-campbell | [e7539c] changed readme to .txt |
This project is for the ASCII Art Ladder It converts PLCOpenXML files of ladder POUs exported from CODESYS into a beautiful ASCII Art It will initially use: CODESYS Ladder Editor CODESYS PLCOpenXML Export CODESYS Scripting Engine / IronPython Python XML Some new ASCII Ladder format defined in this project Step 1: User will create the ladder in CODESYS Ladder Editor. User will compile the ladder without any errors. Step 2: User will export just one single ladder routine to PLCOpenXML Step 3: User will run the PLCOpenXMLLadderToASCIILADDER.py script, with the correct arguments Step 4: The script will look for a declaration header as plain text and save this Step 5: The script will read every subelement of <LD>. Ones it can't understand will be put in an exceptions tag Step 6: The script will arrange all of the ladder elements into rows and columns. This new element array will also list branches in down / in up / out down / out up Step 7: The script will write each row and column to a text file in ASCII Art Ladder format Step 8: The script will list all truncated names, and complete all truncated EXECUTE blocks Example File Output: //This is a rung comment (*Also a rung comment*) (**Mabe a nicer * Way to do multiline comments *) (** supported features: * 001 ‘Network’ * 002 ‘Box’ * 002 ‘Assignment’ * (003 FB, 003 FN) ‘Box with EN/ENO’ * 002 ‘Input’ * 005 ‘Label’ * 005 ‘Contact’ * 005 ‘Coil’ * 005 Negated Contant * 006 Branches (note, branches always close!) * 007 Set coil * 007 Reset coil * 008 short circuit evaluation (SCE) (Toggle Parallel Mode) (I dislike this enough I make you use extended ascii) * 008 Negation (I dislike this enough I make you use extended ascii) * 009 Jump * 010 Return * 011 Network Comment State * 012 FBD/LD/IL Element ‘Execute’ * 013 Names are too long (abreviation section) * I think that's everything actually. *) (** Declaration Section: * Exact copy of the declaration section, with some indentation * Note any indentation that is the same for each line will be removed *) {Declaration} PROGRAM POU VAR END_VAR {/Declaration} (** Abbreviation Section: * Sure it can get confusing. Maybe later can alter it so not fixed width ladder * For importing, it is OK to change the abbrevioations however you please * Rules: Generally if too long: * take first three letters and last three and add a ~0 through ~9 * If more than 10 have same first three and same last three, the 11th becomes ~~10 * If there is one or more points in the variable name, shorten the first three and but the point before the ~ *) {Abbreviaitons} Nam~0GHT := NameEIGHT; Nam~1GHT := NameONE_HUNDRED_AND_EIGHT; Nam~2GHT := NameI_CANT_WEIGHT; F_C~0ate := F_Calculate; FB.~0ate := FB_Timer.Calculate; {/Abbreviations} (** Execution Section: * If the execution block is too big to fit, * either width ways or column ways, write it's Execution here. * Note any indentation that is the same for each line will be removed *) {Executions} {~1} thisvariable := actuallyToolong; REsult := Function(); //I added a comment //If line too long it gets truncated // >6 line, ~ bottom right IF TRUE THEN DoSomethingCool; END_IF; {/~1} {/Executions} {Ladder} 001 ||. . . . . . || || || ||------------------------------------------------------------|| || || 002 ||. . . ________ . || || NameEIGH | F_Name | NameEIGH || ||----] [------------------------Input_01|--------------( )---|| || Variable==In_out01| || || =InOut2 | || || Variable--Input2 | || || =InOut3 | || || | Out01--Variable || || | Out02--Variable || || |________| || || || 003 ||. . . ________ . || || NameEIGH NameEIGH Instance--FB_Name8| NameEIGH || ||----] [-------] [--------------EN ENO---------------( )---|| || -Input01 | || || | Out01- || || =In_out01| || || =Inout2 | || || |________| || || || 004 ||. . . ________ . || || NameEIGH | F_Name | NameEIGH || ||----] [------------------------EN ENO---------------( )---|| || Variable--Input01 | || || | Out01--Variable || || Variable==In_out01| || || Variable==Inout2 | || || |________| || || || 005 ||. . . . . . || myLabel || NameEIGH NameEIGH NameEIGH || ||----] [-------]/[-------------------------------------( )---|| || || 006 ||. . . . . . || || NameEIGH NameEIGH NameEIGH || ||+---] [--++---] [------------+------------------------( )---|| ||| || | || ||| || . | || |||NameEIGH||NameEIGH NameEIGH| || ||+---] [--++---] [-------]/[--+ || || || 007 ||. . . . . . || || NameEIGH NameEIGH NameEIGH || ||----------------------------------(R)-------(S)---+---(S)--+|| || | ||| || | ||| || |NameEIGH||| || +---(R)--+|| || || 008 ||. . . . . . || || NameEIGH ASCII181 NameEIGH || ||----] [---╬---] [--------------------------------╬----( )---|| || ║ ║ || || ║ . ________ ║ || || ║ASCII206 Instance--FB_Name8| ║ || || ╬---] [--------------EN ENO----------╬ || || NegInVarø-Input01 | || || | Out01-øASCII155 || || =In_out01| || || =Inout2 | || || |________| || || || 009 ||. . . . . . || || myLabel || ||----------------------------------------------------<JUMP>--|| || || 010 ||. . . . . . || || || ||---------------------------------------------------<RETURN>-|| || || 011 ||##. . . . . . || ||## NameEIGH || ||##----] [--------------------------------------------<RETURN>-|| ||## || 012 ||. . . __________________________ . || || NameEIGH | Execute ~1 | || ||----] [---------------EN ENO------------|| || |thisvariable := actuallyT~| || || |REsult := Function(); | || || |//I added a comment | || || |//If line too long it get~| || || |// >6 line, ~ bottom right| || || |IF TRUE THEN | || || |_________________________~| || || || 013 ||. . . ________ . || || FB.~0ate Nam~1GHT |F_C~0ate| Nam~2GHT || ||----] [---+---] [--------------EN ENO----------+----( )---|| || | NegInVarø-Input01 | | || || | | Out01-øASCII155| || || | =In_out01| | || || | =Inout2 | | || || | |________| | || || | . ________ | || || |Nam~0GHT Instance--FB_Timer| | || || +---] [--------------EN ENO----------+ || || NegInVarø-Input01 | || || | Out01-øASCII155 || || =In_out01| || || =Inout2 | || || |________| || || || {/Ladder}