Skip to content

Zeugwerk/Plaincat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vscode-plaincat

Proof of concept for importing and exporting TwinCAT PLCs into Visual Studio Code such that is possible to view and edit code.

  • The project implements minimal effort way to convert TwinCAT files (XML files) into plain text via regular expressions
  • and a stripped down version of Zeugwerk's Structured Text Parser to make it possible to convert plain text into TwinCAT XMLs. While the full parser creates a full abstract syntax tree (AST) for Structured Text, the stripped down version only provides the bare minimum AST to convert plain text to TwinCAT XMLs. The full parser for now is only available on demand, contact us if you are interested.

plaincat

How to use (Command Line Interface)

  • Install the extension Serhioromano.vscode-st so you get syntax highlighting for structured text in vscode.

  • To convert a TwinCAT plcproj file to plain text (.st files), run the following command

     Plaincat encode --source <path_to_plcproj> --target <path_to_folder>
    
  • To convert from plain text (.st files) back to TwinCAT, run the following command

     Plaincat decode --target <path_to_empty_folder_for_new_plcproj> --source <path_to_folder_containing_st_files>
    

How to use (vscode extension)

Note that this is not streamlined yet, so instead of just installing an extension from the marketplace you got to

  • Compile the C# project and copy the executable to C:\appl\vscode-plaincat\vscode-plaincat\bin\ (if you want to use a different path modify vscode-plaincat/src/extension.ts
  • Compile the vscode extension by opening the folder vscode-plaincat and running npx vsce package in vscode's terminal
  • In vscode open 'Extensions' and install vscode-plaincat-0.0.1.vsix by clicking on 'Install from VSIX...'
  • Reload vscode
  • To convert an existing plcproj to plaintext open the command palette by pressing Shift+Ctrl+P and run the command plaincat.decode and follow the instructions
  • To convert plaintext back to a plcproj open the command palette by pressing Shift+Ctrl+P and run the command plaincat.encode and follow the instructions