/**
* @meaning :主界面控制
* @author :zhongjianxiong
* @date :2017-5
*/
#include "mainwindow.h"
static int Button_X = 1020; //280
static int Button_Y = -220;
static int Button_W = 50;
static int Button_H = 60;
static int Button_x_Space = 130;
static int Button_y_Space = 90; //设置Button之间的距离
//static QString arrive_station_path = "../arrivestation/到达站点";
static QString arrive_station_path = "../arrivestation/";
static QString goto_station_path = "../gotostatiom/去站点";
static QString map_station_dir = "../map_station/";
static QString maps_dir = "../maps/";
static QString block_music_dir = "../block_sound/";
static QString run_time_dir = "./run_num.dll";
static QString wharf_station = "../tmp/wharf.txt";
static QString charge_file_dir = "../tmp/charge.txt";
static QString area_file = "../tmp/regulateArea.txt";
static QString Ultrason_area_file = "../tmp/ultrason.txt";
static QString Shelf_station = "../tmp/shelf.txt";
static QString add_station = "../tmp/addStation.txt";
static QString full_empty_shelf = "../tmp/fullEmptyShelf.txt";
static QString Shelf_size = "../tmp/shelfSize.txt";
static QString regulatStation_dir = "../tmp/regulateStationArea.txt";
static QString muchArea_dir = "../tmp/muchArea.txt";
static QString autoDoor_file = "../tmp/autoDoor.txt";
static qint8 charge_times = 0; //保存充电成功次数,超过三次认为充电成功
static qint8 area_leave = 0; //判断是否是第一次进入区域
static QString send_gotoStationNum = "0"; //保存要发送站点的站点ID,确保机器在充电站时先出充电站,再执行其它站点任务
static QString AGVS_sendto_stationNum = "-1";//保存中控发来的站点ID
static bool isShelf_task = false; //AGVS发送的是升降货架任务
static bool close_auto_flag = false; //关闭自动门
static bool last_autoDoot_cleal_flag = false;
static bool autoDoor_flag = false; //自动门开关标志
static bool in_autoDoor_room = false; //true表示AGV在自动门房间内
static bool out_autoDoor_room = true; //true表示AGV在自动门房间外
static QString leaveRoom_station = ""; //出自动门房间后 AGV的目标点
static int loop_time_save = -1; //保存要循环的次数
static int button_state = 0; //按键状态,0表示所有任务按钮都没有按下
static bool route_stat = false;
static int central_task_num = 0;
static int waitTask_time = 0; //中控发送等待任务的等待时间
static int task_randnum_flag = -1;
static int num = 0;
static double charge_back_distance = 0;
static int current_floor_pos = 2; //AGV正处于的楼层编号
static int task_floor_pos = 1; //任务目的地的楼层编号
static QString run_time_num = "20180801";
//体验版本时间设置
int days = 60;
int hours = 0;
int minutes = 0;
int run_time_true = minutes + hours*60 + days*24*60;
//static int charge_count = 0;//zhongjianxiong
//static int charge_fail_count = 0;
/*
1021和1022是success时候,切换模式才能切换成功
1021查询机器人当前的重定位状态
1022查询机器人当前的载如地图状态
要使1021为success,必须重定位后用2003确认定位正确
2003确认重定位正确
从机器人上下载地图功能暂时没有用
*/
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),SendStationPoint(false)
{
robot_status_set = new TcpClient(19204);
robot_control = new TcpClient(19205);
robot_task = new TcpClient(19206);
robot_core = new TcpClient(19207); //配置API
restart_shutdonw = new TcpClient(19208);
// out_server1 = new Server(NULL,19204);
// out_server2 = new Server(NULL,19205);
// out_server3 = new Server(NULL,19206);
// out_server4 = new Server(NULL,19207);
// out_server5 = new Server(NULL,19208);
//Download_map_client = new TcpClient(8080);
//QPalette palette;
//QPixmap pixmap("1.jpg");
// palette.setBrush(QPalette::Window, QBrush(pixmap));
this->setFixedSize(1280,800);
this->setWindowTitle("激光机器人控制系统");
//this->setPalette(palette);
// this->setStyleSheet("background-image:url(../picture/mainPicture.jpg)");
background_label = new QLabel(this);
background_label->resize(1280,800);//(1280,725);1280
// QMovie* GifBackgound = new QMovie(":/picture/mainPicture.gif");
// GifBackgound->start();
// background_label->setMovie(GifBackgound);
// background_label->setStyleSheet("background-image:url(../picture/mainPicture.jpg)");
background_label->setStyleSheet("border-image: url(:/picture/mainPicture.jpg)");
//this->setWindowFlags(Qt::FramelessWindowHint);
this->setFont(QFont("方正兰亭黑_GBK", 11, QFont::Black));
Button_init();
Label_init();
dialog_st = new QDialog;
combox_st = new QComboBox(dialog_st);
configure_route_ = new path_run;
music_player = new MusicPlayer;
// music_player->player->play();
regulate_player = new QMediaPlayer;
station_player = new QMediaPlayer;
// connect(Mute_,SIGNAL(clicked(bool)),music_player,SLOT(togglePlayback())); //静音函数
connect(buttonArry[MUSIC],SIGNAL(clicked(bool)),music_player,SLOT(togglePlayback())); //静音函数
Delay_Send_Date= new QTimer;; //延时发送命令定时器 -- 因这个接口板命令冲突 - 故加 ---虎雷加2021-09-07
connect(Delay_Send_Date,SIGNAL(timeout()),this,SLOT(Delay_Send_Date_slot()));
task_route_timer = new QTimer;
connect(task_route_timer,SIGNAL(timeout()),this,SLOT(task_route_slot()));
wait_time_timer = new QTimer;
connect(wait_time_timer,SIGNAL(timeout()),this,SLOT(wait_time_timer_slot()));
connect(robot_status_set,SIGNAL(robot_status_set_signal(QByteArray)),this,SLOT(robot_status_set_slot(QByteArray)));
get_robot_stat_timer = new QTimer;
connect(get_robot_stat_timer,SIGNAL(timeout()),this,SLOT(get_robot_stat_slot()));
connect(robot_task,SIGNAL(station_back_msg()),this,SLOT(station_back_msg_slot()));
connect(robot_task,SIGNAL(turn_round_back()),this,SLOT(turn_round_back_slot()));
load_map_name = new QDialog(this); //加载地图界面
load_map_box = new QComboBox(load_map_name); //显示存储的地图名字
connect(robot_status_set,SIGNAL(connect_stat(QString)),this,SLOT(connect_stat_slot(QString)));
read_autoDoor_area();
read_shelf_station();
read_add_station();
read_full_empty_shelf();
read_shelf_size();
detection_arrive_shelf = new QTimer; //检测AGV是否已钻入货架
connect(detection_arrive_shelf,SIGNAL(timeout()),this,SLOT(arrive_shelf_timer_slot()));
litre_drop_timer = new QTimer;
connect(litre_drop_timer,SIGNAL(timeout()),this,SLOT(litre_drop_timer_slot()));
read_wharf_station();
read_charge_station();
// myserial = new MySerial;
serialToLanTcp = new serial_to_lan(8080);
myserial_timer = new QTimer;
connect(myserial_timer,SIGNAL(timeout()),this,SLOT(myserial_timer_slot()));
if(!myserial_timer->isActive())
myserial_timer->start(500);
connect(serialToLanTcp,SIGNAL(red_line(QByteArray)),this,SLOT(handle_charge_slot(QByteArray)));
connect(serialToLanTcp,SIGNAL(connect_stat(QString)),this,SLOT(SLconnect_stat_slot(QString)));
Beeper_serial = new Beeper_Serial; //呼叫器类
connect(Beeper_serial,SIGNAL(send_beeper_st(QByteArray)),this,SLOT(beeper_call_slot(QByteArray)));//保存呼叫器发来的站点
location_Dialog = new QDialog;
location_box = new QComboBox(location_Dialog);
transfer_station_inform(); //读取地图中的站点信息到另一个文件中
charge_timer = new QTimer; //检测是否配置了自动充�