diff --git a/emulator.cpp b/emulator.cpp index 72b106f..f75b40b 100644 --- a/emulator.cpp +++ b/emulator.cpp @@ -57,9 +57,9 @@ char scheduler_start_signal = 1; char auto_mode_pause = 0; char hla_night_mode = 0; -short hla_exchange_zone = ZONE_GALVANIZING_1; +short hla_exchange_zone = ZONE_GALVANIZING_2; -short hla_disabled_zones = 0; +short hla_disabled_zones = DISABLED_GAL_1 | DISABLED_GAL_2; short etching_zone = -2, galvanizing_zone = -2; @@ -228,7 +228,7 @@ static void showAll() { image_init(); image_draw_borders(); char tmp[64]; - sprintf(tmp, "Lock1=%2d Lock2=%2d E=%d G=%d", robot1_lock_zone, robot2_lock_zone, etching_zone, galvanizing_zone); + sprintf(tmp, "Lock2=%2d Lock1=%2d FNZ=%d", robot2_lock_zone, robot1_lock_zone, get_first_night_zone()); image_insert_sprite(0, 2, tmp); collectBarrelsStatistic(); @@ -245,8 +245,7 @@ static void showAll() { char flag_r = ' '; if (b.flags.is_night) { flag_r = 'n'; - } - if (b.flags.is_empty) { + } else if (b.flags.is_empty) { flag_r = 'e'; } diff --git a/scheduler.c b/scheduler.c index 76d306b..24ad773 100644 --- a/scheduler.c +++ b/scheduler.c @@ -339,21 +339,28 @@ void scheduler_main() case 3: // ну а теперь конечная стадия - собсна раздача команд - // отдельно просчитаем все для первого робота - if (robot1_code.PC < 0) { - schedule_one_robot(ROBOT_1); - } - - // и отдельно для второго + // сначала выдаем команды второму роботу if (robot2_code.PC < 0) { if (robot2.dx.current_zone < ZONE_WASHING_1A) { - // вернемся к стадии 2, ну его нафиг, код переписывать - + // то же самое что и во второй стадии, только без инкремента стадии + if (robot2_code.PC < 0) { + robot2_lock_zone = ZONE_ETCHING_2; + robot2_code.barrel_id = -1; + robot2_code.code[0] = ROBOT_CMD_DOWN(); + robot2_code.code[1] = ROBOT_CMD_MOVE_TO_ZONE(ZONE_WASHING_1A); + robot2_code.code[2] = ROBOT_CMD_END(); + robot2_code.PC = 0; + } } else { schedule_one_robot(ROBOT_2); } } + // потом первому + if (robot1_code.PC < 0) { + schedule_one_robot(ROBOT_1); + } + break; default: diff --git a/utils.c b/utils.c index df4e8ee..7335a8d 100644 --- a/utils.c +++ b/utils.c @@ -38,7 +38,7 @@ short get_first_night_zone() { for (short nz = 0; nz < 9; nz++) { char found = 0; for (short i = 0; i < BARRELS_COUNT; i++) { - if (barrels[i].flags.is_exist && barrels[i].zone == NIGHT_ZONES[nz] && !barrels[i].flags.is_night) { + if (barrels[i].flags.is_exist && barrels[i].zone == NIGHT_ZONES[nz] && barrels[i].flags.is_night) { found = 1; } } @@ -59,9 +59,14 @@ short _get_dest_zone(struct barrel *bar) { // если это зона обмена и барабан пустой if (bar->zone == hla_exchange_zone && bar->flags.is_empty) { - return ZONE_LOAD_1; + if (hla_night_mode) { + return get_first_night_zone(); + } else { + return ZONE_LOAD_1; + } } + switch (bar->zone) { case ZONE_LOAD_2: // загрузка 2, только в нее можно грузить новые барабаны, нужно обезжиривание @@ -478,7 +483,7 @@ void create_operation(struct robot_code *code, short barrel_id, const short star short cmd_index = 0; - if (!one_robot_mode && !hla_night_mode) { + if (!one_robot_mode) { if (robot_id == 1) { short tmp = dest_zone; if (start_zone < dest_zone) { diff --git a/utils.h b/utils.h index 58aa645..21c31b6 100644 --- a/utils.h +++ b/utils.h @@ -404,6 +404,8 @@ char is_accessible_zone(short zone); */ char increment_zone(short zone); +short get_first_night_zone(); + #ifdef EMULATOR void debug_print_robot_code(const struct robot_code *code, const short robot_id, int fd); #endif