Skip to main content
Code Review

Return to Question

Tweeted twitter.com/StackCodeReview/status/1149423239862599684
More specific title
Link
Toby Speight
  • 87.9k
  • 14
  • 104
  • 325

C program to parse Parse source code of anotherthe RAPID robot-automation language

Became Hot Network Question
Spelling and markdown fixes
Source Link
Toby Speight
  • 87.9k
  • 14
  • 104
  • 325

I am new to C, and I have very little formal education on programming (Although I am currently in college). I work as a Robot Automation technician, and me and my team are required to document a lot of things. I wrote a program that we run on our robot computers to do this, but the language (RAPID by ABB Robotics) had it'sits limitations, and the versions of operating systems vary from machine to machine. To get to the point, I decided that I need to re-write the application in a general language that would be better suited for this.

Basically, this program reads the source code that I have pasted in a textfiletext file and writes all of the data to a csv file, which is then pasted into an excelExcel workbook that is formatted as a report.

In the textfiletext file that contains the source code that this program reads, there is an 80x15×ばつ15 array that I need all of the data from, and then there Is a procedure in the program that I look for after that.

In the 80x15×ばつ15 array, each array represents a robot position, and each index is a value that is used for that position. 4 of the digits are whole numbers that actually represent a binary byte, while the other 2 digits are a float and a whole number. All of the data that I get from the array goes into a struct array that is in another C file.

After the array is read, it looks for a procedure called SPRAY_POSITIONS()SPRAY_POSITIONS(). In this function we have all the statements that tell the robot how to move and etc, For each statement, I increment my counter, and when the RETURNRETURN statement is reached It, it will exit and store the total positions used in that function. Most of this data is also stored in the same struct array.

I apologize in advance if this is not a good question for this site, but I'm the only one at my work that knows how to program anything besides an ifif/elseelse statement or a looploop, and I definitely want to get some feedback on my code so that I can improve. Thank you all for your time!

I am new to C, and I have very little formal education on programming (Although I am currently in college). I work as a Robot Automation technician, and me and my team are required to document a lot of things. I wrote a program that we run on our robot computers to do this, but the language (RAPID by ABB Robotics) had it's limitations, and the versions of operating systems vary from machine to machine. To get to the point I decided that I need to re-write the application in a general language that would be better suited for this.

Basically, this program reads the source code that I have pasted in a textfile and writes all of the data to a csv file, which is then pasted into an excel workbook that is formatted as a report.

In the textfile that contains the source code that this program reads, there is an 80x15 array that I need all of the data from, and then there Is a procedure in the program that I look for after that.

In the 80x15 array, each array represents a robot position, and each index is a value that is used for that position. 4 of the digits are whole numbers that actually represent a binary byte, while the other 2 digits are a float and a whole number. All of the data that I get from the array goes into a struct array that is in another C file.

After the array is read, it looks for a procedure called SPRAY_POSITIONS(). In this function we have all the statements that tell the robot how to move and etc, For each statement, I increment my counter, and when the RETURN statement is reached It will exit and store the total positions used in that function. Most of this data is also stored in the same struct array.

I apologize in advance if this is not a good question for this site, but I'm the only one at my work that knows how to program anything besides an if/else statement or a loop, and I definitely want to get some feedback on my code so that I can improve. Thank you all for your time!

I am new to C, and I have very little formal education on programming (Although I am currently in college). I work as a Robot Automation technician, and me and my team are required to document a lot of things. I wrote a program that we run on our robot computers to do this, but the language (RAPID by ABB Robotics) had its limitations, and the versions of operating systems vary from machine to machine. To get to the point, I decided that I need to re-write the application in a general language that would be better suited for this.

Basically, this program reads the source code that I have pasted in a text file and writes all of the data to a csv file, which is then pasted into an Excel workbook that is formatted as a report.

In the text file that contains the source code that this program reads, there is an ×ばつ15 array that I need all of the data from, and then there Is a procedure in the program that I look for after that.

In the ×ばつ15 array, each array represents a robot position, and each index is a value that is used for that position. 4 of the digits are whole numbers that actually represent a binary byte, while the other 2 digits are a float and a whole number. All of the data that I get from the array goes into a struct array that is in another C file.

After the array is read, it looks for a procedure called SPRAY_POSITIONS(). In this function we have all the statements that tell the robot how to move and etc, For each statement, I increment my counter, and when the RETURN statement is reached, it will exit and store the total positions used in that function. Most of this data is also stored in the same struct array.

I apologize in advance if this is not a good question for this site, but I'm the only one at my work that knows how to program anything besides an if/else statement or a loop, and I definitely want to get some feedback on my code so that I can improve. Thank you all for your time!

Added contents of header files
Source Link
RobotMan
  • 359
  • 4
  • 9

The Spray Positions header contents

/************************************************************************
* The functions in this module are used
* to set data for a spray position struct
* There are 80 structures created, since
* there are a max of 80 spray positions.
*
* @param positionNumber is the current
* spray position to be updated
*
* @param movement type is the type of move
* used in that position, L,J,C
*
* @param zoneType is the type of zone used
* in the position, FINE,Z1-100
*
* @param additionalCommands is used to
* store other commands associated with a certain
* position such as SET, RESET, PULSDO etc
*
* @param sweepPattern is the formatted version
* of the binary byte that tells us which nozzles
* are turned on during the sweep function for the
* specified position.
* Example: *0011* would translate to *12* and *12*
* would be the pattern used
*
* @param dwellPattern is the same as the sweepPattern,
* but is used to show which nozzles are on during the
* dwell function of the specified position
*
* @param sweepSpeed is how fast the robot is moving
* to the specified position
*
* @param dwellTime is how long the robot stays
* at the specified position before moving to the
* next positon
**************************************************************************/
void setPositionMoveType(int positionNumber, char* movementType);
void setPositionZoneType(int positionNumber, char* zoneType);
void setPositionAdditionalCommands(int positionNumber, char* additionalCommands);
void setPositionSweepPattern(int positionNumber, char* sweepPattern);
void setPositionDwellPattern(int positionNumber, char* dwellPattern);
void setPositionSweepSpeed(int positionNumber, char* sweepSpeed);
void setPositionDwellTime(int positionNumber, char* dwellTime);
void writeSprayData(int totalSprayPositions, FILE* fp);
/* Used for debugging, prints all data for each position that is used */
void printArrayDataByPosition(int position);

The rapid parser header file (I don't think I actually should have included this in my main code because It comes from the same module)

/*********************************************************
* Gets all of the data stored in the program file
* Then updates each spray position struct
* With the information obtained from that file
*********************************************************/
void getDataFromRapidSrcFile();
/* Returns the total amount of spray positions in use */
int getTotalPositions();

The Spray Positions header contents

/************************************************************************
* The functions in this module are used
* to set data for a spray position struct
* There are 80 structures created, since
* there are a max of 80 spray positions.
*
* @param positionNumber is the current
* spray position to be updated
*
* @param movement type is the type of move
* used in that position, L,J,C
*
* @param zoneType is the type of zone used
* in the position, FINE,Z1-100
*
* @param additionalCommands is used to
* store other commands associated with a certain
* position such as SET, RESET, PULSDO etc
*
* @param sweepPattern is the formatted version
* of the binary byte that tells us which nozzles
* are turned on during the sweep function for the
* specified position.
* Example: *0011* would translate to *12* and *12*
* would be the pattern used
*
* @param dwellPattern is the same as the sweepPattern,
* but is used to show which nozzles are on during the
* dwell function of the specified position
*
* @param sweepSpeed is how fast the robot is moving
* to the specified position
*
* @param dwellTime is how long the robot stays
* at the specified position before moving to the
* next positon
**************************************************************************/
void setPositionMoveType(int positionNumber, char* movementType);
void setPositionZoneType(int positionNumber, char* zoneType);
void setPositionAdditionalCommands(int positionNumber, char* additionalCommands);
void setPositionSweepPattern(int positionNumber, char* sweepPattern);
void setPositionDwellPattern(int positionNumber, char* dwellPattern);
void setPositionSweepSpeed(int positionNumber, char* sweepSpeed);
void setPositionDwellTime(int positionNumber, char* dwellTime);
void writeSprayData(int totalSprayPositions, FILE* fp);
/* Used for debugging, prints all data for each position that is used */
void printArrayDataByPosition(int position);

The rapid parser header file (I don't think I actually should have included this in my main code because It comes from the same module)

/*********************************************************
* Gets all of the data stored in the program file
* Then updates each spray position struct
* With the information obtained from that file
*********************************************************/
void getDataFromRapidSrcFile();
/* Returns the total amount of spray positions in use */
int getTotalPositions();
Source Link
RobotMan
  • 359
  • 4
  • 9
Loading
lang-c

AltStyle によって変換されたページ (->オリジナル) /