Exemplo n.º 1
0
QStringList SerialPort::ports()
{
    QList<QSerialPortInfo> list = QSerialPortInfo::availablePorts();
    QStringList stringList;
    for(auto p = list.begin(); p != list.end(); p++)
        stringList.append(p->portName());
    return stringList;
}
Exemplo n.º 2
0
void Transcode(CStdString &file)
{
	OrkLogManager::Instance()->Initialize();

	ObjectFactory::GetSingleton()->Initialize();

	ConfigManager::Instance()->Initialize();

	std::list<ACE_DLL> pluginDlls;
	LoadPlugins(pluginDlls);

	// Register in-built filters
	FilterRef filter(new AlawToPcmFilter());
	FilterRegistry::instance()->RegisterFilter(filter);
	filter.reset(new UlawToPcmFilter());
	FilterRegistry::instance()->RegisterFilter(filter);
	filter.reset(new GsmToPcmFilter());
	FilterRegistry::instance()->RegisterFilter(filter);
	filter.reset(new IlbcToPcmFilter());
	FilterRegistry::instance()->RegisterFilter(filter);
	filter.reset(new AudioGainFilter());
	FilterRegistry::instance()->RegisterFilter(filter);
	filter.reset(new G722ToPcmFilter());
	FilterRegistry::instance()->RegisterFilter(filter);
	filter.reset(new SpeexDecoder() );
	FilterRegistry::instance()->RegisterFilter(filter);
	filter.reset(new G721CodecDecoder());
	FilterRegistry::instance()->RegisterFilter(filter);
	
	// Register in-built tape processors and build the processing chain
	BatchProcessing::Initialize();
	Reporting::Initialize();
	TapeFileNaming::Initialize();

	if (!ACE_Thread_Manager::instance()->spawn(ACE_THR_FUNC(BatchProcessing::ThreadHandler)))
	{
		LOG4CXX_INFO(LOG.rootLog, CStdString("Failed to create batch processing thread"));
	}


	
	// Transmit the tape to the BatchProcessing
	CStdString ProcessorName("BatchProcessing");
	TapeProcessorRef bp = TapeProcessorRegistry::instance()->GetNewTapeProcessor(ProcessorName);
	CStdString portName("SinglePort");
	AudioTapeRef tape(new AudioTape(portName, file));
	bp->AddAudioTape(tape);
	
	// Make sure it stops after processing
	tape.reset();
	bp->AddAudioTape(tape);

	// Wait for completion
	while(!Daemon::Singleton()->IsStopping())
	{
		ACE_OS::sleep(1);
	}
}
/*!
 * \brief  功能概述 打开串口
 * \param  参数描述 strPortName_是串口名,strBaudNo_是波特率,strDataBits_是数据位,strStopBits_是停止位,strParity_是校验方式
 * \return 返回值描述 成功打开返回true,若打开失败则返回false
 * \author zzy
 * \date   2015/5/27
 */
bool CSerialPort::OpenSerialPort(const QString strPortName_, const QString strBaudNo_,
                                 const QString strDataBits_, const QString strStopBits_, const QString strParity_)
{
    InitBaudNo(strBaudNo_);
    InitDataBits(strDataBits_);
    InitStopBits(strStopBits_);
    InitParity(strParity_);

    ///打开串口
    QString tempPortName = strPortName_;
    setPortName(strPortName_);
    if (!open(QIODevice::ReadWrite)) {
        qDebug()<<QString("Can't open %1, error code %2").arg(portName()).arg(error());
        int nPortNumber = tempPortName.remove("COM").toInt();
        QString strPortName2 = tr("ttyS%1").arg(nPortNumber);
        setPortName(strPortName2);
        if (!open(QIODevice::ReadWrite)) {
            qDebug()<<QString("Can't open %1, error code %2").arg(portName()).arg(error());
            QString strPortName3 = tr("ttyO%1").arg(nPortNumber);
            setPortName(strPortName3);
            if (!open(QIODevice::ReadWrite)) {
                qDebug()<<QString("Can't open %1, error code %2").arg(portName()).arg(error());
                return false;
            }
        }
    }
    ///  设置波特率
    setBaudRate((QSerialPort::BaudRate)m_nBaudNo);

    ///  设置数据位
    setDataBits((QSerialPort::DataBits)m_nDataBits);

    ///  设置停止位
    setStopBits((QSerialPort::StopBits)m_nStopBits);

    ///  设置校验方式
    setParity((QSerialPort::Parity)m_nParity);

    if (!setFlowControl(QSerialPort::NoFlowControl)) {
        qDebug()<<QString("Can't set no flow control to port %1, error code %2").arg(portName()).arg(error());
        return false;
    }
    return true;

}
Exemplo n.º 4
0
bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
{
    Q_Q(QSerialPort);

    // FIXME: Maybe need added check an ReadWrite open mode?
    Q_UNUSED(mode)

    if (!loadDevices()) {
        q->setError(QSerialPort::UnknownError);
        return false;
    }

    RCommServ server;
    errnum = server.Connect();
    if (errnum != KErrNone) {
        q->setError(decodeSystemError());
        return false;
    }

    if (systemLocation.contains("BTCOMM"))
        errnum = server.LoadCommModule(KBluetoothModuleName);
    else if (systemLocation.contains("IRCOMM"))
        errnum = server.LoadCommModule(KInfraRedModuleName);
    else if (systemLocation.contains("ACM"))
        errnum = server.LoadCommModule(KACMModuleName);
    else
        errnum = server.LoadCommModule(KRS232ModuleName);

    if (errnum != KErrNone) {
        q->setError(decodeSystemError());
        return false;
    }

    // In Symbian OS port opening only in R/W mode?
    TPtrC portName(static_cast<const TUint16*>(systemLocation.utf16()), systemLocation.length());
    errnum = descriptor.Open(server, portName, ECommExclusive);

    if (errnum != KErrNone) {
        q->setError(decodeSystemError());
        return false;
    }

    // Save current port settings.
    errnum = descriptor.Config(restoredSettings);
    if (errnum != KErrNone) {
        q->setError(decodeSystemError());
        return false;
    }

    detectDefaultSettings();
    return true;
}
Exemplo n.º 5
0
bool MidiInterface::open()
{
    if(_isVirtual)
    {
        if(_hasVirtualSupport)
        {
            openIn(-1);
            loadMapping();
        }
        return _hasVirtualSupport;
    }
    // object name is used as portname
    return open(portName());
}
Exemplo n.º 6
0
int QextSerialPort::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QIODevice::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 15)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 15;
    } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
        if (_id < 15)
            *reinterpret_cast<int*>(_a[0]) = -1;
        _id -= 15;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = portName(); break;
        case 1: *reinterpret_cast< QueryMode*>(_v) = queryMode(); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setPortName(*reinterpret_cast< QString*>(_v)); break;
        case 1: setQueryMode(*reinterpret_cast< QueryMode*>(_v)); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 2;
    } else if (_c == QMetaObject::RegisterPropertyMetaType) {
        if (_id < 2)
            *reinterpret_cast<int*>(_a[0]) = -1;
        _id -= 2;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Exemplo n.º 7
0
/*!
 * \brief SerialDev::configPort - Parametri per configurare la porta seriale
 * \return true se riesce a configurare correttamente la porta seriale
 */
bool SerialDev::configPort (const QString &name)
{
    bool debugVal = m_debug;
    m_debug = true;
    setPortName(name);

    if (!open(QIODevice::ReadWrite)) {
        QString testo = QString("Can't open %1, error code %2")
                    .arg(portName()).arg(error());
        debug(testo);
        return false;
    }

    if (!setBaudRate(QSerialPort::Baud115200)) {
        QString testo = QString("Can't set rate 115200 baud to port %1, error code %2")
                     .arg(portName()).arg(error());
        debug(testo);
        return false;
    }

    if (!setDataBits(QSerialPort::Data8)) {
        QString testo = QString("Can't set 8 data bits to port %1, error code %2")
                     .arg(portName()).arg(error());
        debug(testo);
        return false;
    }

    if (!setParity(QSerialPort::NoParity)) {
        QString testo = QString("Can't set no patity to port %1, error code %2")
                     .arg(portName()).arg(error());
        debug(testo);
        return false;
    }

    if (!setStopBits(QSerialPort::OneStop)) {
        QString testo = QString("Can't set 1 stop bit to port %1, error code %2")
                     .arg(portName()).arg(error());
        debug(testo);
        return false;
    }

    if (!setFlowControl(QSerialPort::NoFlowControl)) {
        QString testo = QString("Can't set no flow control to port %1, error code %2")
                     .arg(portName()).arg(error());
        debug(testo);
        return false;
    }

    connect(this, SIGNAL(error(QSerialPort::SerialPortError)),
            this, SLOT(errorSlot(QSerialPort::SerialPortError)));
    connect(this, SIGNAL(readyRead()), this, SLOT(fromDeviceSlot()));

    m_debug = debugVal;
   return true;
}
bool SerialPortInfo::isValid() const
{
    if (!loadDevices())
        return false;

    RCommServ server;
    TInt r = server.Connect();
    if (r != KErrNone)
        return false;

    RComm port;
    TPtrC portName(static_cast<const TUint16*>(systemLocation().utf16()), systemLocation().length());
    r = port.Open(server, portName, ECommExclusive);
    if (r == KErrNone)
        port.Close();
    return r == KErrNone || r == KErrLocked;
}
Exemplo n.º 9
0
bool MidiInterface::openIn(const unsigned int portIndex)
{
    if(_rtMidiIn)
    {
        if(_connected)
        {
            qDebug() << Q_FUNC_INFO
                     << "Already opened port";
            return false;
        }
        else
        {
            _portIndex = portIndex;
            try {
                if(_isVirtual)
                {
                    _rtMidiIn->openVirtualPort(portName().toStdString());
                }
                else
                {
                    qDebug() << "port:" << portIndex << Q_FUNC_INFO << this;

                    _rtMidiIn->openPort(portIndex);

                }
                // Set our callback function.  This should be done immediately after
                // opening the port to avoid having incoming messages written to the
                // queue.
                _rtMidiIn->setCallback( &_midiCallback, this );

                // Don't ignore sysex, timing, or active sensing messages.
                _rtMidiIn->ignoreTypes( false, !_acceptClock, true );
                if(_id == -1)
                    setId(_midi->grabMidiInterfaceId());
                _connected = true;
                qDebug() << "MIDI In connected to: " << this->portName();
                emit(connected());
            } catch ( RtError &error ) {
                error.printMessage();
                _connected = false;
            }
        }
    }
    return _connected;
}
Exemplo n.º 10
0
status_t
ClientNode::PrepareToConnect(const media_source &src,
                             const media_destination &dst,
                             media_format *format, media_source *out_source,
                             char *name)
{
    printf("ClientNode::PrepareToConnect\n");

    if (dst.port == ControlPort())
        return B_MEDIA_BAD_SOURCE;

    if (src.port != ControlPort() || src.id != 0)
        return B_MEDIA_BAD_SOURCE;

    if (format->type != B_MEDIA_RAW_AUDIO
            && format->type != B_MEDIA_UNKNOWN_TYPE) {
        return B_MEDIA_BAD_FORMAT;
    }

    JackPort* port;
    JackPortList* outputs = fOwner->GetOutputPorts();

    for (int i = 0; i < outputs->CountItems(); i++) {
        port = outputs->ItemAt(i);

        media_output* output = port->MediaOutput();
        if (output->source.id == src.id
                && output->destination.id == dst.id) {

            if (port->IsConnected())
                return B_MEDIA_ALREADY_CONNECTED;

            *out_source = src;

            BString portName(jack_port_name((jack_port_t*) port));
            portName.CopyInto(name, 0, portName.Length());

            printf("Connecting to %s\n", name);
            format->SpecializeTo(&fFormat);
            return B_OK;
        }
    }

    return B_MEDIA_BAD_SOURCE;
}
Exemplo n.º 11
0
void MainWindow::on_startButton_clicked()
{
    if(ui->startButton->text()=="Start")
    {

        QString portName(ui->COMComboBox->currentText());
        if ("" == portName)
            QMessageBox::information(this, "startButtonClicked", "No COM selected.", QMessageBox::Ok);

        //定时截屏
        qDebug() << "Start timer";
        try {
            mp_sitLogic->start();
            mp_faceLogic->start();
        } catch(const QString &e)
        {
            QMessageBox::information(this, "start button clicked", e, QMessageBox::Ok);
            return ;
        }
        mp_cameraTimer->start(4000);
        mp_sitProcTimer->start(3000);
        ui->COMComboBox->setEnabled(false);
        ui->startButton->setText("Stop");
        ui->startInfo->setPlainText("Classification Starts");

        // logger
        mp_logger = new Logger(mp_faceLogic, mp_sitLogic);
        connect(this, &MainWindow::startLog, mp_logger, &Logger::start);
        connect(this, &MainWindow::stopLog, mp_logger, &Logger::stop);
        connect(mp_logger, &Logger::stopped, this, &MainWindow::deleteLogger);

        emit startLog();
    }
    else
    {
        emit stopLog();
        mp_cameraTimer->stop();
        mp_sitProcTimer->stop();
        mp_sitLogic->stop();
        mp_faceLogic->stop();
        ui->COMComboBox->setEnabled(true);
        ui->startButton->setText("Start");
        ui->startInfo->setPlainText("Classification Stopped");
    }
}
Exemplo n.º 12
0
void MainWindow::on_trainSit_triggered()
{
    try{
        mp_db->openDB();
    } catch(const QString &e)
    {
        QMessageBox::information(this, "train_triggered", e, QMessageBox::Ok);
        return ;
    }

    bool b_exist = true;
    try{
        mp_db->selectXml(); // check if model exists
        mp_db->closeDB();
    } catch (const QString& e)
    {
        mp_db->closeDB();
        if (!e.contains("no record", Qt::CaseInsensitive))
        {
            QMessageBox::information(this, "train_triggered", e, QMessageBox::Ok);
            return ;
        }
        else b_exist = false;
    }
    if (b_exist)
    {
        int res = QMessageBox::question(this, "Predictor model detected.",
                              "Would you like to replace the existed model?",
                              QMessageBox::Yes, QMessageBox::No);
        if (res == QMessageBox::No) return;
    }

    QString portName(ui->COMComboBox->currentText());
    if (portName == "")
    {
        QMessageBox::information(this, "No COM", "No COM is selected.", QMessageBox::Ok);
        return;
    }

    ui->COMComboBox->setEnabled(false);
    collectDialog c(portName, b_exist);
    c.exec();
    ui->COMComboBox->setEnabled(true);
}
Exemplo n.º 13
0
Unmask::Unmask(int channel)
{
    mChannel=channel;
	mWrapAdd=0;

    objSynapse=new Synapse(
        128,   // x dim
        128,   // y dim
        2,     // neighborhood
        0.8,   // sigma
        2.0,   // threshold
        1.0,   // alpha // 5.0
        250.0, // tau
        5000   // accTime
    );

    std::string portName("/optflow/vectors:o");
    objSynapse->openPort(portName);
}
Exemplo n.º 14
0
void MainWindow::on_connectButton_clicked()
{
    QString portName(ui->COMComboBox->currentText());

    // open serial port
    QList<QString> devList;
    try{
        if ("" == portName) throw QString("No selected COM.");
        CSerialReader reader(portName);
        devList = reader.findDev();
        if (devList.empty())
            throw QString("No device found");
    } catch (const QString& e)
    {
        QMessageBox::information(this, "Error", e, QMessageBox::Ok);
        return;
    }

    connectDialog c(portName, devList);
    c.exec();
}
Exemplo n.º 15
0
bool WinPcapPort::setExclusiveControl(bool exclusive) 
{
    QString portName(adapter_->Name + strlen("\\Device\\NPF_"));
    QString bindConfigFilePath(QCoreApplication::applicationDirPath()
                + "/bindconfig.exe");
    QString status;

    qDebug("%s: %s", __FUNCTION__, portName.toAscii().constData());

    if (!QFile::exists(bindConfigFilePath))
        return false;

    status = exclusive ? "disable" : "enable";

    QProcess::execute(bindConfigFilePath, 
            QStringList() << "comp" << portName << status);

    updateNotes(); 

    return (exclusive == hasExclusiveControl());
}
Exemplo n.º 16
0
void FilterPortWidget::startDrag()
{
    if(!draggable())
        return;
    QDrag *drag = new QDrag(this);
    QMimeData *mimeData = new QMimeData;
    QStringList data;
    if(isOutput())
        data << "output";
    else
        data << "input";
    data << QByteArray::number(filterId());
    data << portName().toLocal8Bit();
    data << QByteArray::number(portType());

    mimeData->setData("application/x-olvis-port", data.join("#").toLocal8Bit());
    drag->setPixmap(grab());
    drag->setHotSpot(QPoint(width()/2, height()/2));
    drag->setMimeData(mimeData);
    drag->exec(Qt::CopyAction);
}
Exemplo n.º 17
0
void MainWindow::_show_updatePortNames()
{
  //we extract the names of the currently available serial ports
  QList<QSerialPortInfo> availablePorts = QSerialPortInfo::availablePorts();
  std::list<QString> availablePortNames;
  for(auto it = availablePorts.cbegin(); it != availablePorts.cend(); ++it)
    availablePortNames.push_back(it->portName());

  //has any serial port been closed since the last check?
  for(auto it = m_show_arraySerialPortActions.begin(); it != m_show_arraySerialPortActions.end(); ++it)
  {
    QString currentPortName = (*it)->text();
    bool found = false;
    for(auto jt = availablePortNames.begin(); !found && jt != availablePortNames.end(); ++jt)
      if((*jt) == currentPortName)
      {
        //this serial port is still available, and we already have a QAction for it, we remove it from availablePortNames
        std::cout << "found : " << currentPortName.toStdString() << std::endl;
        jt = availablePortNames.erase(jt);
        found = true;
      }
    if(!found)
    {
      //this serial port is no longer available, we delete it from the GUI.
      m_show_serialPortActionGroup->removeAction(*it);
      m_show_menuSerialPort->removeAction(*it);
      it = m_show_arraySerialPortActions.erase(it);
    }
  }

  //Now, availablePortNames only contains the names of the newly available serial ports.
  for(auto it = availablePortNames.cbegin(); it != availablePortNames.cend(); ++it)
  {
    QAction * serialPortAction = new QAction(*it, this);
    serialPortAction->setCheckable(true);
    m_show_arraySerialPortActions.push_back(serialPortAction);
    m_show_serialPortActionGroup->addAction(serialPortAction);
    m_show_menuSerialPort->addAction(serialPortAction);
  }
}
Exemplo n.º 18
0
bool QSerialPortInfo::isBusy() const
{
    QString lockFilePath = serialPortLockFilePath(portName());
    if (lockFilePath.isEmpty())
        return false;

    QFile reader(lockFilePath);
    if (!reader.open(QIODevice::ReadOnly))
        return false;

    QByteArray pidLine = reader.readLine();
    pidLine.chop(1);
    if (pidLine.isEmpty())
        return false;

    qint64 pid = pidLine.toLongLong();

    if (pid && (::kill(pid, 0) == -1) && (errno == ESRCH))
        return false; // PID doesn't exist anymore

    return true;
}
Exemplo n.º 19
0
bool WinPcapPort::hasExclusiveControl() 
{
    QString portName(adapter_->Name + strlen("\\Device\\NPF_"));
    QString bindConfigFilePath(QCoreApplication::applicationDirPath()
                + "/bindconfig.exe");
    int exitCode;

    qDebug("%s: %s", __FUNCTION__, portName.toAscii().constData());

    if (!QFile::exists(bindConfigFilePath))
        return false;

    exitCode = QProcess::execute(bindConfigFilePath, 
            QStringList() << "comp" << portName);

    qDebug("%s: exit code %d", __FUNCTION__, exitCode);

    if (exitCode == 0)
        return true;
    else
        return false;
}
Exemplo n.º 20
0
/*!
 * \brief Rs232DevicePrivate::configPort - Parametri per configurare la porta seriale
 * \return true se riesce a configurare correttamente la porta seriale
 */
bool Rs232DevicePrivate::configPort ()
{
    if (!open(QIODevice::ReadWrite)) {
        QString testo = QString("Can't open %1, error code %2")
                    .arg(portName()).arg(error());
        debug(testo);
        return false;
    }

    if (!setBaudRate(QSerialPort::Baud115200)) {
        QString testo = QString("Can't set rate 115200 baud to port %1, error code %2")
                     .arg(portName()).arg(error());
        debug(testo);
        return false;
    }

    if (!setDataBits(QSerialPort::Data8)) {
        QString testo = QString("Can't set 8 data bits to port %1, error code %2")
                     .arg(portName()).arg(error());
        debug(testo);
        return false;
    }

    if (!setParity(QSerialPort::NoParity)) {
        QString testo = QString("Can't set no patity to port %1, error code %2")
                     .arg(portName()).arg(error());
        debug(testo);
        return false;
    }

    if (!setStopBits(QSerialPort::OneStop)) {
        QString testo = QString("Can't set 1 stop bit to port %1, error code %2")
                     .arg(portName()).arg(error());
        debug(testo);
        return false;
    }

    if (!setFlowControl(QSerialPort::NoFlowControl)) {
        QString testo = QString("Can't set no flow control to port %1, error code %2")
                     .arg(portName()).arg(error());
        debug(testo);
        return false;
    }

    return true;
}
Exemplo n.º 21
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;

    QString portName("ttyUSB0");
    bool found = false;
    foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) {
        //qDebug() << "Name        : " << info.portName();
        if (info.portName().startsWith(portName)) {
            found = 1;
            w.serial.setPort(info);
            if (!w.serial.open(QIODevice::ReadWrite)) {
                qDebug() << "ERROR: cant connect to " << info.portName();
                exit(1);
            }
            w.serial.setBaudRate(QSerialPort::Baud57600);
        }
    }
    if (!found) {
        portName = "ttyS0";
        foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) {
            //qDebug() << "Name        : " << info.portName();
            if (info.portName().startsWith(portName)) {
                found = 1;
                w.serial.setPort(info);
                if (!w.serial.open(QIODevice::ReadWrite)) {
                    qDebug() << "ERROR: cant connect to " << info.portName();
                   // exit(1);
                }
                w.serial.setBaudRate(QSerialPort::Baud57600);
            }
        }
        if (!found) {
            qDebug() << "ERROR: cant find port " << portName;
          //  exit(1);
        }
    }
Exemplo n.º 22
0
void CATBase::ConstructL()
/**
 * This is the second phase constructor for the CATBase class.  It configures the port
 * specified by the combination of KCsyName and KPortName.  Configuration data includes
 * baud rate, data bits, stop bits, and handshake.
 *
 * @leave	This method leaves if there is an error configuring the port or potentially
 *			from the NewL method which is called.
 */
	{
	TFileName csyName(KCsyName);
	TName portName(KPortName);
	iIo=CATIO::NewL(csyName,portName);
	TCommConfigV01 commConfig;
	commConfig.iRate=KBaudRate;
	commConfig.iDataBits=KDataBits;
	commConfig.iStopBits=KStopBits;
	commConfig.iHandshake=KHandshake;

	TCommConfig commConfigWrapper(commConfig);
	TInt r=iIo->ConfigurePort(commConfigWrapper);
	User::LeaveIfError(r);
	}
Exemplo n.º 23
0
Widget::Widget(int delay_before, int delay_after, int max_time, int num_images, QString *serial_device, QString *camera_ip, QString *image_prefix, bool interlace_levels, bool numbers, QWidget *parent, QGLFormat *format, bool rotate, QString *file_list_name)
  :QGLWidget(*format, parent)
  , m_current(0)
  , m_state(Stopped)
  , m_delay_before(delay_before)
  , m_delay_after(delay_after)
  , m_max_time(max_time)
  , m_num_images(num_images)
  , m_port_value(0x0)
  , m_first_run(true)
  , m_serial_device(serial_device)
  , m_camera_ip(camera_ip)
  , m_image_prefix(image_prefix)
  , m_interlace_levels(interlace_levels)
  , m_numbers(numbers)
  , m_rotate(rotate)
  , m_file_list_name(file_list_name)
{
  setAutoFillBackground(false);
  makeCurrent();
  
  // Escape shortcut
  QShortcut *sh = new QShortcut(QKeySequence(trUtf8("Esc")), this);
  connect(sh, SIGNAL(activated()), this, SLOT(close()));
  m_total=0;

  // Info0
  QMessageBox::information(this, tr("Info"),tr("HIT 'ESC' to CLOSE"));  
 
  QString portName(*m_serial_device);           
  listener = new PortListener(portName);        // signals get hooked up internally


    m_direction=1;

  // Images
   for( int i=0; i<m_num_images; i++)
     {
       QPixmap p;
       QString fname=*m_image_prefix;
       fname+=QString("%1.bmp").arg(i, 5, 'f', 0, '0');
       bool ret = p.load(fname);
       if(ret)
    m_pixmap << p;
       else
    m_pixmap << QPixmap();  // empty in case of missing images
   }

//       qDebug() << "Loading image:" << i << "=" << ret;
//     }

  // create num_images empty images...

  m_curr_angle = 0;
  m_draw_count = 0;
  //  m_timer = new QTimer(this);
  m_timespent= new QElapsedTimer();
  m_timelastdraw= new QElapsedTimer();
  //  connect(m_timer, SIGNAL(timeout()), this, SLOT(update()));
  //  m_timer->setInterval(50); // times a second we paint drawmax frames 
  
  // if list then open it

 file_list=false;


  if(*m_file_list_name!="")
    {
      flist= new QFile();
      file_list=true;
      flist->setFileName(*file_list_name);
    if(!flist->open(QIODevice::ReadOnly))
	{
	  qDebug() << "Couldn't open file_list " << *file_list_name;
	  std::exit(1);
	}
      //open 
    }
	
	QTimer::singleShot(0, this, SLOT(startShow()));
}
Exemplo n.º 24
0
// Tooltip text builder.
QString qjackctlPortItem::tooltip (void) const
{
	return portName();
}
Exemplo n.º 25
0
PortId FilterPortWidget::portId() const
{
    return PortId(filterId(), portName());
}
Exemplo n.º 26
0
void ProcessorOutputPortWidget::mouseDoubleClickEvent(QMouseEvent *)
{
    QString newName = QInputDialog::getText(0, tr("Change port name"), tr("Enter new name"), QLineEdit::Normal, portName());
    if(!newName.isEmpty())
        emit rename(portId(), newName);
}
Exemplo n.º 27
0
/*!
 * \brief Rs232DevicePrivate::handleMsgRxFromDevice - Decodifica il tipo di messaggio
 *                                                  - e lo gestisce
 * \param buffer
 */
void Rs232DevicePrivate::handleMsgRxFromDevice (const QByteArray & buffer)
{
    if (m_debug)
    {
        QDebug debugBuffer = qDebug();
        debugBuffer << headDebug << "Rx ";
        quint8 var;
        foreach (var, buffer) {
            debugBuffer << hex << var;
        }
    }

//    qDebug() << "handleMsgRxFromDevice" << portName();
    quint8 lunghezza = buffer.length();
    if (lunghezza < 1)
    {
        debug("Messaggio from Device corto");
        return;
    }

    switch (buffer[0])
    {
    case TIPO_RX_RS232_CAN_ID:
        if (lunghezza < 7)
        {
            debug("Messaggio CAN_ID corto");
            return;
        }

        if (m_timerAutodelete.isActive())
        {
            // La prima volta in assoluto scrivo un messaggio di debug per sapere a quale seriale
            // il converter e' stato trovato
            QString testo = QString ("Converter found on %1").arg(portName());
            debug(testo);
        }

        // Interrompo il timer per l'auto-delete
        m_timerAutodelete.stop();

        // Mi tengo da parte i valori se mai un Client dovesse chiedermeli
        m_statoInterno = buffer.at(1);
        m_versioneMajor = buffer.at(2);
        m_versioneMinor = buffer.at(3);
        m_comstat      = buffer.at(6);

        // Faccio sapere a Rs232Device che ho trovato un converter e che quindi puo' interrompere
        // la ricerca
        emit fondItSignal();

        // Ripeto il GET_ID ogni 6 sec: ma serve? Si, perche'cosi' rinfresco m_comstat e m_statoInterno
        m_timerSendGetId.start(6000);
        break;

    case TIPO_RX_RS232_CAN_MSG:
    {
        if (lunghezza != 13)
        {
            debug("Lunghezza messaggio CAN_MSG non std");
            return;
        }

        // Tolgo solo il primo carattere
        QByteArray bufferOut = buffer.right(buffer.length() - 1);
        // Messaggio da spedire verso i Clients
        emit toClientsSignal(bufferOut);
    }
        break;
    }
}
Exemplo n.º 28
0
Rs232DevicePrivate::~Rs232DevicePrivate()
{
    qDebug() << headDebug << "DTor" << portName();
}
Exemplo n.º 29
0
Lv2Plugin::Lv2Plugin(const LilvPlugin *plugin, LilvInstance *instance,
                     const Lv2Constants &uris, Lv2Worker *worker) :
    plugin(plugin), instance(instance), midiOutputCount(0),
    controlConnections(4), newControlMappingsQueue(16), worker(worker)
{
    // audio inputs
    audioInputCount = lilv_plugin_get_num_ports_of_class(plugin, uris.lv2AudioPort, uris.lv2InputPort, 0);
    audioInputIndex = new uint32_t[audioInputCount];
    audioInput = new AudioConnector[audioInputCount];

    // audio outputs
    audioOutputCount = lilv_plugin_get_num_ports_of_class(plugin, uris.lv2AudioPort, uris.lv2OutputPort, 0);
    audioOutputIndex = new uint32_t[audioOutputCount];
    audioOutput = new AudioConnection*[audioOutputCount];
    for(uint32_t i = 0; i < audioOutputCount; i++) {
        audioOutput[i] = new AudioConnection(this);
        audioOutput[i]->clear();
    }

    // initialize port structures
    uint32_t numPorts = lilv_plugin_get_num_ports(plugin);
    uint32_t audioInputCounter = 0;
    uint32_t audioOutputCounter = 0;
    for(uint32_t i = 0; i < numPorts; i++) {
        const LilvPort *port = lilv_plugin_get_port_by_index(plugin, i);
        if(lilv_port_is_a(plugin, port, uris.lv2AudioPort)) {
            if(lilv_port_is_a(plugin, port, uris.lv2InputPort)) {
                audioInputIndex[audioInputCounter++] = i;
            }
            else if(lilv_port_is_a(plugin, port, uris.lv2OutputPort)) {
                audioOutputIndex[audioOutputCounter++] = i;
            }
        } else if(lilv_port_is_a(plugin, port, uris.lv2ControlPort)
                  && lilv_port_is_a(plugin, port, uris.lv2InputPort)) {
            // get control name
            const LilvNode* symbol = lilv_port_get_symbol(plugin, port);
            std::string portName(lilv_node_as_string(symbol));

            // create, connect and hash new control port object
            Lv2ControlPort *newPort = new Lv2ControlPort();
            LilvNode *dfault, *minimum, *maximum;
            lilv_port_get_range(plugin, port, &dfault, &minimum, &maximum);
            newPort->dfault = dfault ? lilv_node_as_float(dfault) : 0;
            newPort->minimum = lilv_node_as_float(minimum);
            newPort->maximum = lilv_node_as_float(maximum);
            lilv_instance_connect_port(instance, i, &(newPort->value));
            controlMap[portName] = newPort;

        } else if(lilv_port_is_a(plugin, port, uris.lv2AtomPort)) {
            // is it a MIDI/atom input?
            LilvNodes *atomBufferType = lilv_port_get_value(plugin, port, uris.lv2AtomBufferType);
            LilvNodes* atomSupports = lilv_port_get_value(plugin, port, uris.lv2AtomSupports);
            if (lilv_port_is_a(plugin, port, uris.lv2InputPort) &&
                    lilv_nodes_contains(atomBufferType, uris.lv2AtomSequence)
                    && lilv_nodes_contains(atomSupports, uris.lv2MidiEvent)) {
                // create new inputs and connect to atom sequence location
                Lv2MidiInput *newAtomPort = new Lv2MidiInput();
                lilv_instance_connect_port(instance, i, newAtomPort->getAtomSequence());
                midiInputList.add(newAtomPort);
            }
            else if (lilv_port_is_a(plugin, port, uris.lv2OutputPort)) {
                //atomSequence->atom.type = Lv2PluginFactory::instance()->uridMapper.uriToId(LV2_ATOM__Sequence);
                Lv2MidiOutput *midiOutput = new Lv2MidiOutput(this);
                lilv_instance_connect_port(instance, i, midiOutput->getAtomSequence());
                midiOutputList.add(midiOutput);
                midiOutputCount++;
            }
            else {
                // warn
                std::cout << "!!! unknown atom port at index " << i << ": " << lilv_node_as_string(lilv_port_get_name(plugin, port)) << std::endl;
            }
            lilv_nodes_free(atomSupports);
            lilv_nodes_free(atomBufferType);
        } else {
            lilv_instance_connect_port(instance, i, NULL);
            std::cout << "!!! unknown port at index " << i << ": " << lilv_node_as_string(lilv_port_get_name(plugin, port)) << std::endl;
        }
    }
}