Исправление ночного режима, мелкие исправления логики

This commit is contained in:
VladislavOstapov 2023-02-12 20:47:08 +03:00
parent 2297d7c7a9
commit ee7658b131
4 changed files with 29 additions and 16 deletions

View File

@ -57,9 +57,9 @@ char scheduler_start_signal = 1;
char auto_mode_pause = 0; char auto_mode_pause = 0;
char hla_night_mode = 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; short etching_zone = -2, galvanizing_zone = -2;
@ -228,7 +228,7 @@ static void showAll() {
image_init(); image_init();
image_draw_borders(); image_draw_borders();
char tmp[64]; 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); image_insert_sprite(0, 2, tmp);
collectBarrelsStatistic(); collectBarrelsStatistic();
@ -245,8 +245,7 @@ static void showAll() {
char flag_r = ' '; char flag_r = ' ';
if (b.flags.is_night) { if (b.flags.is_night) {
flag_r = 'n'; flag_r = 'n';
} } else if (b.flags.is_empty) {
if (b.flags.is_empty) {
flag_r = 'e'; flag_r = 'e';
} }

View File

@ -339,21 +339,28 @@ void scheduler_main()
case 3: case 3:
// ну а теперь конечная стадия - собсна раздача команд // ну а теперь конечная стадия - собсна раздача команд
// отдельно просчитаем все для первого робота // сначала выдаем команды второму роботу
if (robot1_code.PC < 0) {
schedule_one_robot(ROBOT_1);
}
// и отдельно для второго
if (robot2_code.PC < 0) { if (robot2_code.PC < 0) {
if (robot2.dx.current_zone < ZONE_WASHING_1A) { 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 { } else {
schedule_one_robot(ROBOT_2); schedule_one_robot(ROBOT_2);
} }
} }
// потом первому
if (robot1_code.PC < 0) {
schedule_one_robot(ROBOT_1);
}
break; break;
default: default:

11
utils.c
View File

@ -38,7 +38,7 @@ short get_first_night_zone() {
for (short nz = 0; nz < 9; nz++) { for (short nz = 0; nz < 9; nz++) {
char found = 0; char found = 0;
for (short i = 0; i < BARRELS_COUNT; i++) { 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; found = 1;
} }
} }
@ -59,9 +59,14 @@ short _get_dest_zone(struct barrel *bar) {
// если это зона обмена и барабан пустой // если это зона обмена и барабан пустой
if (bar->zone == hla_exchange_zone && bar->flags.is_empty) { 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) { switch (bar->zone) {
case ZONE_LOAD_2: case ZONE_LOAD_2:
// загрузка 2, только в нее можно грузить новые барабаны, нужно обезжиривание // загрузка 2, только в нее можно грузить новые барабаны, нужно обезжиривание
@ -478,7 +483,7 @@ void create_operation(struct robot_code *code, short barrel_id, const short star
short cmd_index = 0; short cmd_index = 0;
if (!one_robot_mode && !hla_night_mode) { if (!one_robot_mode) {
if (robot_id == 1) { if (robot_id == 1) {
short tmp = dest_zone; short tmp = dest_zone;
if (start_zone < dest_zone) { if (start_zone < dest_zone) {

View File

@ -404,6 +404,8 @@ char is_accessible_zone(short zone);
*/ */
char increment_zone(short zone); char increment_zone(short zone);
short get_first_night_zone();
#ifdef EMULATOR #ifdef EMULATOR
void debug_print_robot_code(const struct robot_code *code, const short robot_id, int fd); void debug_print_robot_code(const struct robot_code *code, const short robot_id, int fd);
#endif #endif