Мелкие исправления
This commit is contained in:
parent
2e4a560f74
commit
7bd6275bac
@ -185,7 +185,7 @@ int main() {
|
||||
// b.zone = (short) abs(random() % 20);
|
||||
// }
|
||||
|
||||
barrels[5] = makeBarrel(1, 10, 3);
|
||||
barrels[5] = makeBarrel(1, 21, 3);
|
||||
|
||||
current_tic = 0;
|
||||
const char* message = nullptr;
|
||||
|
20
robot.cpp
20
robot.cpp
@ -9,15 +9,6 @@ bool robot1_offset_pos = false;
|
||||
bool robot2_offset_pos = false;
|
||||
|
||||
|
||||
static short get_barrel(char robot_id) {
|
||||
for (short i = 0; i < BARRELS_COUNT; i++) {
|
||||
if (barrels[i].flags.robot == robot_id) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// true означает что движение закончено
|
||||
static bool robot_move(robot_regs& r, short target, char robot_id) {
|
||||
// после перемещения мы явно в точной позиции
|
||||
@ -44,6 +35,12 @@ static void emulate_robot(robot_code &code, robot_regs& r, char robot_id) {
|
||||
if (code.PC < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// приватизируем бочку
|
||||
if (code.barrel_id >= 0) {
|
||||
barrels[code.barrel_id].flags.robot = robot_id;
|
||||
}
|
||||
|
||||
const short cmd_arg = code.code[code.PC] & (~ROBOT_CMD_MASK);
|
||||
|
||||
switch (code.code[code.PC] & ROBOT_CMD_MASK) {
|
||||
@ -127,6 +124,7 @@ static void emulate_robot(robot_code &code, robot_regs& r, char robot_id) {
|
||||
break;
|
||||
|
||||
case ROBOT_CMD_INC_ZONE:
|
||||
// TODO сделать так, чтобы зоны переключались с учетом отключенных зон
|
||||
if (cmd_arg == ROBOT_ZONE_ETCH) {
|
||||
std::cout << "robot " << robot_id << " increment etching..." << std::endl;
|
||||
etching_zone = (etching_zone + 1) & 1;
|
||||
@ -142,6 +140,10 @@ static void emulate_robot(robot_code &code, robot_regs& r, char robot_id) {
|
||||
case ROBOT_CMD_END:
|
||||
default:
|
||||
code.PC = -1;
|
||||
// де-приватизируем бочку
|
||||
if (code.barrel_id >= 0) {
|
||||
barrels[code.barrel_id].flags.robot = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
13
scheduler.c
13
scheduler.c
@ -159,10 +159,10 @@ short can_move(struct barrel* bar) {
|
||||
|
||||
case ZONE_UNLOAD:
|
||||
// последняя промывка, нужно разрешение на выгрузку
|
||||
if (schedulerOneRobotMode) {
|
||||
if (schedulerOneRobotMode && schedulerUnloadButton) {
|
||||
// нужно промывку загрузку 0
|
||||
if (!zone_is_busy(17)) {
|
||||
return 17;
|
||||
if (!zone_is_busy(ZONE_LOAD_1)) {
|
||||
return ZONE_LOAD_1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -305,8 +305,7 @@ void debug_print_robot1_code() {
|
||||
break;
|
||||
|
||||
case ROBOT_CMD_TMR_SET:
|
||||
printf(" set barrel timer %d secs\n", cmd_arg);
|
||||
i++;
|
||||
printf(" set barrel timer %d secs\n", robot1_code.code[++i]);
|
||||
break;
|
||||
|
||||
case ROBOT_CMD_SET_LOCK_ZONE:
|
||||
@ -350,6 +349,7 @@ void schedule_robot_1() {
|
||||
tasks[i].dest_zone = can_move(barrels + i);
|
||||
}
|
||||
|
||||
// TODO добавить вставку lock-point'ов на задачах на несколько роботов
|
||||
// найти подходящую задачу
|
||||
if (schedulerOneRobotMode) {
|
||||
short target_task = scheduler_find_task(tasks, robot1.dx.current_zone);
|
||||
@ -367,8 +367,11 @@ void schedule_robot_1() {
|
||||
if (tasks[target_task].start_zone == 22) {
|
||||
robot1_code.code[cmd_index++] = ROBOT_CMD_MOVE_OFF;
|
||||
robot1_code.code[cmd_index++] = ROBOT_CMD_UP;
|
||||
if (robot1.dx.current_zone != 21) {
|
||||
robot1_code.code[cmd_index++] = ROBOT_CMD_MOVE_TO_ZONE | 21;
|
||||
robot1_code.code[cmd_index++] = ROBOT_CMD_MOVE_OFF;
|
||||
}
|
||||
robot1_code.code[cmd_index++] = ROBOT_CMD_DOWN_2;
|
||||
robot1_code.code[cmd_index++] = ROBOT_CMD_MOVE_TO_ZONE | 22;
|
||||
} else {
|
||||
robot1_code.code[cmd_index++] = ROBOT_CMD_MOVE_TO_ZONE | tasks[target_task].start_zone;
|
||||
|
Reference in New Issue
Block a user