Добавление полноценного режима двух роботов
This commit is contained in:
59
emulator.cpp
59
emulator.cpp
@@ -43,9 +43,11 @@ short hla_time_washing_2 = 20;
|
||||
|
||||
|
||||
char hla_robot1_en = 1;
|
||||
char hla_robot2_en = 0;
|
||||
char hla_robot2_en = 1;
|
||||
char one_robot_mode = (char)(hla_robot1_en ^ hla_robot2_en);
|
||||
char _scheduler_en = 1;
|
||||
char scheduler_en = 1;
|
||||
char scheduler_start_signal = 1;
|
||||
char auto_mode_pause = 0;
|
||||
|
||||
|
||||
short etching_zone = 0, galvanizing_zone = 0;
|
||||
@@ -151,7 +153,31 @@ static void showAll() {
|
||||
|
||||
image_init();
|
||||
image_draw_borders();
|
||||
char tmp[16];
|
||||
char tmp[64];
|
||||
sprintf(tmp, "Lock1=%02d Lock2=%02d", robot1_lock_zone, robot2_lock_zone);
|
||||
image_insert_sprite(0, 2, tmp);
|
||||
|
||||
int barrels_count = 0, barrels_time = 0;
|
||||
static int max_time = 0;
|
||||
for (int i = 0; i < BARRELS_COUNT; i++) {
|
||||
if (barrels[i].flags.is_exist) {
|
||||
barrels_count++;
|
||||
if (barrels[i].zone <= ZONE_LOAD_2 || barrels[i].zone == ZONE_PASSIVATION || barrels[i].zone == ZONE_UNLOAD) {
|
||||
continue;
|
||||
}
|
||||
if (barrels[i].flags.robot == 0 && barrels[i].software_timer < 0) {
|
||||
// время отрицательное, вычитаем его чтобы убрать минус
|
||||
barrels_time -= barrels[i].software_timer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (max_time < barrels_time) {
|
||||
max_time = barrels_time;
|
||||
}
|
||||
|
||||
sprintf(tmp, "barrels=%02d time=%04d max_time=%04d", barrels_count, barrels_time, max_time);
|
||||
image_insert_sprite(0, 25, tmp);
|
||||
|
||||
// рисование бочек
|
||||
for (int i = 0; i < BARRELS_COUNT; i++) {
|
||||
@@ -199,10 +225,10 @@ static void open_socket() {
|
||||
}
|
||||
|
||||
serv_addr.sin_family = AF_INET;
|
||||
serv_addr.sin_port = htons(40090);
|
||||
serv_addr.sin_port = htons(40000);
|
||||
|
||||
// Convert IPv4 and IPv6 addresses from text to binary form
|
||||
if (inet_pton(AF_INET, "192.168.0.160", &serv_addr.sin_addr) <= 0) {
|
||||
if (inet_pton(AF_INET, "127.0.0.1", &serv_addr.sin_addr) <= 0) {
|
||||
printf("\nInvalid address/ Address not supported \n");
|
||||
exit(-1);
|
||||
}
|
||||
@@ -213,26 +239,6 @@ static void open_socket() {
|
||||
}
|
||||
}
|
||||
|
||||
static struct barrel make_barrel(short flags, short zone, short timer) {
|
||||
barrel b;
|
||||
b.flags.raw_word = flags;
|
||||
b.zone = zone;
|
||||
b.software_timer = timer;
|
||||
b.time_degreasing = hla_time_degreasing;
|
||||
b.time_washing_1a = hla_time_washing_1a;
|
||||
b.time_washing_1b = hla_time_washing_1b;
|
||||
b.time_etching = hla_time_etching;
|
||||
b.time_washing_2a = hla_time_washing_2a;
|
||||
b.time_washing_2b = hla_time_washing_2b;
|
||||
b.time_galvanizing = hla_time_galvanizing;
|
||||
b.time_washing_3a = hla_time_washing_3a;
|
||||
b.time_washing_3b = hla_time_washing_3b;
|
||||
b.time_passivation = hla_time_passivation;
|
||||
b.time_washing_4a = hla_time_washing_4a;
|
||||
b.time_washing_4b = hla_time_washing_4b;
|
||||
return b;
|
||||
}
|
||||
|
||||
int main() {
|
||||
open_socket();
|
||||
|
||||
@@ -240,6 +246,9 @@ int main() {
|
||||
const char* message = nullptr;
|
||||
while (true) {
|
||||
_scheduler_software_timer = 1;
|
||||
|
||||
button_load = 1;
|
||||
|
||||
robot_main();
|
||||
scheduler_main();
|
||||
send_str("\033c");
|
||||
|
||||
Reference in New Issue
Block a user