|
@@ -369,6 +369,64 @@ ADCIntelligentVehicle::ADCIntelligentVehicle(QWidget *parent)
|
|
|
|
|
|
ModuleFun funvbox = std::bind(&ADCIntelligentVehicle::UpdateVbox,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
|
|
|
mpaplantrace = iv::modulecomm::RegisterRecvPlus("vbox",funvbox);
|
|
|
+#if 1 //红绿灯
|
|
|
+ ui->lcdTurn->setDigitCount(3); //设置显示几个数字
|
|
|
+ ui->lcdTurn->setMode(QLCDNumber::Dec);
|
|
|
+ ui->lcdTurn->setSegmentStyle(QLCDNumber::Flat);//设置数字字体:Outline,轮廓突出,颜色为背景色;Filled,内部填充型,颜色为黑色;Flat,平面型
|
|
|
+ // 设置数字颜色时要注意: 函数setSegmentStyle(QLCDNumber::Flat)中选择Flat属性,否则在setColor()设置数字颜色时不生效
|
|
|
+ // 设置背景色直接用setStyleSheet()函数设定就可以了。
|
|
|
+ //调色板
|
|
|
+ QPalette lcdpat = ui->lcdTurn->palette();
|
|
|
+ /*设置颜色,整体背景颜色 颜色蓝色,此函数的第一个参数可以设置多种。如文本、按钮按钮文字、多种*/
|
|
|
+ lcdpat.setColor(QPalette::Normal,QPalette::WindowText,Qt::red);
|
|
|
+ //设置当前窗口的调色板
|
|
|
+ ui->lcdTurn->setPalette(lcdpat);
|
|
|
+ //设置背景色
|
|
|
+ //ui->lcdNumber->setStyleSheet("background-color: black");
|
|
|
+ //ui->lcdNumber->display(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"));
|
|
|
+ ui->lcdTurn->display(0);
|
|
|
+
|
|
|
+ ui->lcdLeft->setDigitCount(3);
|
|
|
+ ui->lcdLeft->setMode(QLCDNumber::Dec);
|
|
|
+ ui->lcdLeft->setSegmentStyle(QLCDNumber::Flat);
|
|
|
+ ui->lcdLeft->setPalette(lcdpat);
|
|
|
+ //ui->lcdLeft->setStyleSheet("background-color: black");
|
|
|
+ ui->lcdLeft->display(0);
|
|
|
+
|
|
|
+ ui->lcdStraight->setDigitCount(3);
|
|
|
+ ui->lcdStraight->setMode(QLCDNumber::Dec);
|
|
|
+ ui->lcdStraight->setSegmentStyle(QLCDNumber::Flat);
|
|
|
+ ui->lcdStraight->setPalette(lcdpat);
|
|
|
+ //ui->lcdStraight->setStyleSheet("background-color: black");
|
|
|
+ ui->lcdStraight->display(0);
|
|
|
+
|
|
|
+ ui->lcdRight->setDigitCount(3);
|
|
|
+ ui->lcdRight->setMode(QLCDNumber::Dec);
|
|
|
+ ui->lcdRight->setSegmentStyle(QLCDNumber::Flat);
|
|
|
+ ui->lcdRight->setPalette(lcdpat);
|
|
|
+ //ui->lcdRight->setStyleSheet("background-color: black");
|
|
|
+ ui->lcdRight->display(0);
|
|
|
+ // 新建qimage
|
|
|
+ // QImage img,img2,img3,img4;
|
|
|
+ // 加载图片
|
|
|
+ img.load(":/light_image/diaotou-black.png");
|
|
|
+ img = img.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_38->setPixmap(QPixmap::fromImage(img));
|
|
|
+ img2.load(":/light_image/zuoguai-black.png");
|
|
|
+ img2 = img2.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_33->setPixmap(QPixmap::fromImage(img2));
|
|
|
+ img3.load(":/light_image/zhixing-black.png");
|
|
|
+ img3 = img3.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_35->setPixmap(QPixmap::fromImage(img3));
|
|
|
+ img4.load(":/light_image/youguai-black.png");
|
|
|
+ img4 = img4.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_32->setPixmap(QPixmap::fromImage(img4));
|
|
|
+
|
|
|
+ mTimerState1.setTimerType(Qt::PreciseTimer); //设置计时器的精确程度 Qt::PreciseTimer值为0,含义:精确定时器试图保持毫秒精度
|
|
|
+ connect(&mTimerState1,SIGNAL(timeout()),this,SLOT(onStateTimerTraffic()));//广播发送UDP数据报
|
|
|
+ mTimerState1.start(100); //定时100ms
|
|
|
+
|
|
|
+ #endif
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -665,6 +723,122 @@ void ADCIntelligentVehicle::AutoStart()
|
|
|
|
|
|
}
|
|
|
|
|
|
+void ADCIntelligentVehicle::onStateTimerTraffic()
|
|
|
+{
|
|
|
+ ui->lcdTurn->display((int)ServiceCarStatus.time_turn);
|
|
|
+ ui->lcdLeft->display((int)ServiceCarStatus.time_left);
|
|
|
+ ui->lcdStraight->display((int)ServiceCarStatus.time_straight);
|
|
|
+ ui->lcdRight->display((int)ServiceCarStatus.time_right);
|
|
|
+ switch (ServiceCarStatus.st_turn) {
|
|
|
+ case 0:
|
|
|
+ img.load(":/light_image/diaotou-black.png");
|
|
|
+ img = img.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_38->setPixmap(QPixmap::fromImage(img));
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ img.load(":/light_image/diaotou-green.png");
|
|
|
+ img = img.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_38->setPixmap(QPixmap::fromImage(img));
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ img.load(":/light_image/diaotou-red.png");
|
|
|
+ img = img.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_38->setPixmap(QPixmap::fromImage(img));
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ img.load(":/light_image/diaotou-yellow.png");
|
|
|
+ img = img.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_38->setPixmap(QPixmap::fromImage(img));
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ img.load(":/light_image/diaotou-black.png");
|
|
|
+ img = img.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_38->setPixmap(QPixmap::fromImage(img));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ switch (ServiceCarStatus.st_left) {
|
|
|
+ case 0:
|
|
|
+ img2.load(":/light_image/zuoguai-black.png");
|
|
|
+ img2 = img2.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_33->setPixmap(QPixmap::fromImage(img2));
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ img2.load(":/light_image/zuoguai-green.png");
|
|
|
+ img2 = img2.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_33->setPixmap(QPixmap::fromImage(img2));
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ img2.load(":/light_image/zuoguai-red.png");
|
|
|
+ img2 = img2.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_33->setPixmap(QPixmap::fromImage(img2));
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ img2.load(":/light_image/zuoguai-yellow.png");
|
|
|
+ img2 = img2.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_33->setPixmap(QPixmap::fromImage(img2));
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ img2.load(":/light_image/zuoguai-black.png");
|
|
|
+ img2 = img2.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_33->setPixmap(QPixmap::fromImage(img2));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ switch (ServiceCarStatus.st_straight) {
|
|
|
+ case 0:
|
|
|
+ img3.load(":/light_image/zhixing-black.png");
|
|
|
+ img3 = img3.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_35->setPixmap(QPixmap::fromImage(img3));
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ img3.load(":/light_image/zhixing-green.png");
|
|
|
+ img3 = img3.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_35->setPixmap(QPixmap::fromImage(img3));
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ img3.load(":/light_image/zhixing-red.png");
|
|
|
+ img3 = img3.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_35->setPixmap(QPixmap::fromImage(img3));
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ img3.load(":/light_image/zhixing-yellow.png");
|
|
|
+ img3 = img3.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_35->setPixmap(QPixmap::fromImage(img3));
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ img3.load(":/light_image/zhixing-black.png");
|
|
|
+ img3 = img3.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_35->setPixmap(QPixmap::fromImage(img3));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ switch (ServiceCarStatus.st_right) {
|
|
|
+ case 0:
|
|
|
+ img4.load(":/light_image/youguai-black.png");
|
|
|
+ img4 = img4.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_32->setPixmap(QPixmap::fromImage(img4));
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ img4.load(":/light_image/youguai-green.png");
|
|
|
+ img4 = img4.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_32->setPixmap(QPixmap::fromImage(img4));
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ img4.load(":/light_image/youguai-red.png");
|
|
|
+ img4 = img4.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_32->setPixmap(QPixmap::fromImage(img4));
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ img4.load(":/light_image/youguai-yellow.png");
|
|
|
+ img4 = img4.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_32->setPixmap(QPixmap::fromImage(img4));
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ img4.load(":/light_image/youguai-black.png");
|
|
|
+ img4 = img4.scaled(66,66,Qt::IgnoreAspectRatio);
|
|
|
+ ui->label_32->setPixmap(QPixmap::fromImage(img4));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* @brief ADCIntelligentVehicle::on_pb_open_can_card_clicked
|
|
|
*/
|