DataSink::DataSink(QWidget *parent) : QWidget(parent), ui(new Ui::DataSink) { ui->setupUi(this); on_uartDeviceRefresh_clicked(); tcpServer = new QTcpServer(this); connect(tcpServer, SIGNAL(newConnection()), this, SLOT(tcp_newConnection())); tcpConnection = NULL; tcpIsStarted = false; PortSettings uartSettings; uartSettings.DataBits = DATA_8; uartSettings.FlowControl = FLOW_OFF; uartSettings.Parity = PAR_NONE; uartSettings.StopBits = STOP_1; uartSettings.Timeout_Millisec = 1000; uart = new QextSerialPort(uartSettings, QextSerialPort::EventDriven, this); }
mainw::mainw(QWidget *parent) : QMainWindow(parent), ui(new Ui::mainw) { ui->setupUi(this); HW_wrapper_setup( TIMER_INTERVAL ); memset( buttons, 0, sizeof(bool)*3 ); memset( &cmd_list, 0, sizeof(cmd_list) ); commwait_getstatus = false; commwait_getcoord = false; // setup text boxes QTextOption text_opt; QFont fnt; doc_commands = new QTextDocument("# command list", this); doc_comm_log = new QTextDocument("---- communication log ----", this); fnt = ui->txt_commands->font(); doc_commands->setDefaultFont( fnt ); doc_comm_log->setDefaultFont( fnt ); ui->txt_commands->setDocument( doc_commands ); text_opt = doc_commands->defaultTextOption(); text_opt.setWrapMode( QTextOption::NoWrap ); doc_commands->setDefaultTextOption( text_opt ); doc_commands->setMaximumBlockCount(-1); ui->txt_comm_window->setDocument( doc_comm_log ); ui->txt_comm_window->setFont( fnt ); text_opt = doc_comm_log->defaultTextOption(); text_opt.setWrapMode( QTextOption::NoWrap ); doc_comm_log->setDefaultTextOption( text_opt ); doc_comm_log->setMaximumBlockCount(1000); // set up the graphic display simulator gmem_xy = (uchar*)malloc( DISPSIM_MAX_W * DISPSIM_MAX_H * 3 ); scene_xy = new QGraphicsScene(0, 0, 1330, 460, ui->gw_xy ); QImage image( gmem_xy, DISPSIM_MAX_W, DISPSIM_MAX_H, DISPSIM_MAX_W * 3, QImage::Format_RGB888 ); image.fill(Qt::black ); G_item_xy = new QGraphicsPixmapItem( QPixmap::fromImage( image )); pointer_xy = new QGraphicsEllipseItem( QRect(-3, -3, 5, 5), 0 ); pointer_xy->setPen( QPen(Qt::red) ); pointer_xy->setBrush( QBrush(Qt::NoBrush) ); pointer_z = new QGraphicsLineItem( 1300, 0, 1330, 0 ); pointer_z->setPen( QPen(Qt::red) ); scene_xy->setBackgroundBrush( QBrush(QColor(0x33,0x33,0x33)) ); scene_xy->addItem(G_item_xy); scene_xy->addItem(pointer_xy); scene_xy->addItem(pointer_z); ui->gw_xy->setAlignment(Qt::AlignLeft); ui->gw_xy->setScene(scene_xy); // ui->gw_xy->setScene(scene_z); // init display Disp_Redraw(false); ticktimer = new QTimer( this ); connect(ticktimer, SIGNAL(timeout()), this, SLOT(TimerTick())); ticktimer->start( TIMER_INTERVAL ); client = NULL; comm = new QTcpServer(this); connect(comm, SIGNAL(newConnection()), SLOT(tcp_newConnection())); comm->listen(QHostAddress::Any, 4444); //--- test phase qsrand(0x64892354); main_entry( NULL ); }