Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

YASKAWA JOB file parser #11

Open
CagtayFabry opened this issue Oct 6, 2023 · 0 comments
Open

YASKAWA JOB file parser #11

CagtayFabry opened this issue Oct 6, 2023 · 0 comments
Assignees

Comments

@CagtayFabry
Copy link
Collaborator

CagtayFabry commented Oct 6, 2023

YASKAWA JOB file parser

The goal is to create a Python utility that helps parsing YASKAWA JOB files written in the INFORM language.

structure of JOB file

A JOB file is a single text file made up of two parts:

  1. the header section describing the job metadata, lokal variables, job arguments etc.
  2. the program section containing the robot instructions

The first line of a JOB file (the header section) starts with

/JOB

The header section and the program section are separated by a single line containing the command:

NOP

basic syntax

header section

Different parts of the header section are indicated by / with various levels.
Example:

/JOB
//NAME SET_IDS_FULL
///FOLDERNAME TWINCAT_KOMMUNIKATION

program syntax

Commands in the program section are written in plain text.
In case of structures like for-loops, enclosed commands are indented by one tab \t

Example:

CALL JOB:SET_TCPON ARGF1
TCPON TL#(1)
IFTHENEXP CALLED_IN_MAIN=0
	 CALL JOB:TRIGGER ARGF"PROGRAMM_EIN"
ENDIF
TIMER T=0.50

Comments are indicated by starting the line with ' and have a maximum length of 33 characters.
The formatting does not allow umlaute like ö,ä,ü etc.

Python Tool

First, create a class JobFile that reads an existing job file from the file system.
The class should be called like this: job = JobFile(filename="examplefile.JBI")
The job file should be split into the header section and program section and the full code of each section should be stored (e.g. as individual lines).

After reading the file, the header section should be parsed and the different metadata should be stored as class properties.

For the program section, different rules should be discussed how the program structure should look like, what commands must be present or are not allowed, the order of specific commands etc. .

The individual rules will be listed and discussed in individual issues.
Example rules:

Every program should start with a comment line directly after the NOP statement

The program command SETREG MREG# should only be allowed when the job is listed unter FOLDERNAME TWINCAT_KOMMUNIKATION

learning goals

While developing the tool, the following Python skills should be practiced:

  • reading and working with files (using the with statement)
  • working with python classes (properties, methods etc.)
  • string handling in python
  • creating an executable python script
  • writing output to the command line or a text file
  • working with lists and dictionaries
  • working with regex (advanced)

Example file

/JOB
//NAME SET_IDS_FULL
///FOLDERNAME TWINCAT_KOMMUNIKATION
//POS
///NPOS 0,0,0,0,0,0
//ALIAS
///LVARS 0,5,0,0,0,0,0,0
LI000 WID
LI001 NAHT
LI002 LAGE
LI003 RAUPE
LI004 SCHW
//ARGINFO
///ARGTYPE I,I,I,I,I,,,
///COMMENT
WID
NAHT
LAGE
RAUPE
SCHW



//INST
///DATE 2023/05/03 17:27
///COMM SET WID AND NUMBERS
///ATTR SC,RW
///LVARS 0,5,0,0,0,0,0,0
NOP
'--------------------------------
'Dieser Job setzt einen
'vollstndigen Satz an ID-Nummern
'mit WID
'--------------------------------
'Argumente lesen
GETARG WID IARG#(1)
GETARG NAHT IARG#(2)
GETARG LAGE IARG#(3)
GETARG RAUPE IARG#(4)
GETARG SCHW IARG#(5)
'--------------------------------
'ID Trigger festsetzen
SETREG MREG#(69) 1
'--------------------------------
'WID setzen
CALL JOB:SET_ID ARGFWID ARGF"WID"
'--------------------------------
'Nummern setzen
CALL JOB:SET_IDS ARGFNAHT ARGFLAGE ARGFRAUPE ARGFSCHW
'--------------------------------
'ID Trigger freigeben
SETREG MREG#(69) 0
END

barisccolak added a commit that referenced this issue Oct 20, 2023
barisccolak added a commit that referenced this issue Oct 25, 2023
* Rule class is created, third rule is developing.

* #18 rule defined, #14 rule formatting completed, #20 rule defined, #22 rule class is defined, #17 documentation is started. Ruff check and black check completed.

* #15 new rule implemented.

* #19 implemented (CALL JOB:TRIGGER around ARCON/ARCOFF commands)

* Script is modified to work on a multiple file (#24) and pre-commit created (#23)

* Test folder with two JBI files is created.

* Working on GitHub Actions.

* Update githubaction.yml

* Update githubaction.yml

* Update githubaction.yml

* Update githubaction.yml

* Update githubaction.yml

* Update githubaction.yml

* Update githubaction.yml

* Update githubaction.yml

* Update githubaction.yml

* Update githubaction.yml

* Update githubaction.yml

* Update githubaction.yml

* Update githubaction.yml

* Update githubaction.yml

* Update githubaction.yml

* Update githubaction.yml

* Update githubaction.yml

* Set USERFRAME bug is corrected.

* Extra test files are added.

* check_E (#15) bug is corrected.

* check_B (#11) bug is corrected.

* check_D (#18) int bug argument is corrected.

* Not UTF-8 encoded file handling is added.

* Error Flag is implemented.

* No Foldername is accepted.

* Black applied.

* Some reformating.

* Some reformating.

* Apply suggestions from code review

Co-authored-by: Çağtay Fabry <cagtay.fabry@bam.de>

* Files folder is deleted.

* check_D bug solved.

* check_D bug solved.

* Review notes are implemented and updated.

* Comments are corrected. Segmentation of the classes and error handling improved.

---------

Co-authored-by: Çağtay Fabry <cagtay.fabry@bam.de>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants