Слияние кода из проекта для ПЛК с этим проектом

This commit is contained in:
VladislavOstapov 2022-12-05 11:56:36 +03:00
parent f04fb49a16
commit 5f2bbc4d21

View File

@ -1,8 +1,10 @@
#ifdef EMULATOR
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "emulator.h" #include "emulator.h"
short etching_zone = 0, galvanizing_zone = 0; short etching_zone = 0, galvanizing_zone = 0;
#endif
char zone_is_busy(short zone) { char zone_is_busy(short zone) {
for (short i = 0; i < 10; i++) { for (short i = 0; i < 10; i++) {
@ -40,9 +42,11 @@ short can_move(struct barrel* bar) {
return -2; return -2;
} }
#ifdef EMULATOR
if (!schedulerOneRobotMode) { if (!schedulerOneRobotMode) {
printf("WARMING: нет проверки того, что для перемещения барабана не мешает второй робот\n"); printf("WARMING: нет проверки того, что для перемещения барабана не мешает второй робот\n");
} }
#endif
// дальше нужно проверить, что можно передвигать бочку // дальше нужно проверить, что можно передвигать бочку
@ -339,7 +343,7 @@ static short scheduler_find_task(struct scheduler_task* tasks, const short curr_
} }
} }
#ifdef EMULATOR
void debug_print_robot1_code() { void debug_print_robot1_code() {
// printf("INFO: code length is %d\n", cmd_index); // printf("INFO: code length is %d\n", cmd_index);
printf("Code for R0, B%d:\n", robot1_code.barrel_id); printf("Code for R0, B%d:\n", robot1_code.barrel_id);
@ -412,6 +416,7 @@ void debug_print_robot1_code() {
} }
} }
} }
#endif
void create_operation(const short target_task, const struct scheduler_task* tasks, struct robot_code* code, const short current_zone) { void create_operation(const short target_task, const struct scheduler_task* tasks, struct robot_code* code, const short current_zone) {
@ -574,7 +579,9 @@ void create_operation(const short target_task, const struct scheduler_task* task
code->code[cmd_index++] = ROBOT_CMD_END(); code->code[cmd_index++] = ROBOT_CMD_END();
code->PC = 0; code->PC = 0;
#ifdef EMULATOR
printf("INFO: code length is %d\n", cmd_index); printf("INFO: code length is %d\n", cmd_index);
#endif
} }
@ -599,7 +606,10 @@ void schedule_robot_1() {
if (target_task >= 0) { if (target_task >= 0) {
create_operation(target_task, tasks, &robot1_code, robot1.dx.current_zone); create_operation(target_task, tasks, &robot1_code, robot1.dx.current_zone);
#ifdef EMULATOR
debug_print_robot1_code(); debug_print_robot1_code();
#endif
} }
} else { } else {
printf("WARMING: support only one robot mode\n"); printf("WARMING: support only one robot mode\n");