void AttributeParser::parseMatrixAttribute(MFnDependencyNode & node, MObject & attribute)
    {
        MStatus status;

        MFnMatrixAttribute fnMatrixAttribute(attribute, &status);
        if (!status) return;

        MPlug plug = node.findPlug(attribute, &status);
        if (!status) return;

        MPlugArray plugArray;
        bool hasConnection = plug.connectedTo(plugArray, true, false, &status);
        if (!status) return;
        if (hasConnection)
        {
            MPlug externalPlug = plugArray[0];
            bool externalPlugNull = externalPlug.isNull(&status);
            if (!status) return;
            if (!externalPlugNull)
            {
                MFnAttribute fnAttribute(attribute, &status);
                if (!status) return;

                MString name = fnAttribute.name(&status);
                if (!status) return;

                //MObject pluggedObject = externalPlug.node(&status);
                //if (!status) return;

                // TODO pass matrix to callback? onMatrix(...) instead of onConnection(...)?
                onConnection(plug, name, externalPlug);
            }
        }
    }
Beispiel #2
0
pServer::pServer(QObject *parent):
    QObject(parent)
{
    connect(&_server, SIGNAL(newConnection()), this, SLOT(onConnection()));
    _server.listen(Settings::host(), Settings::port());

    qDebug() << "\n\nServer started. Time:" << QDateTime::currentDateTime().toString() << '\n';
#ifdef FUNC_DEBUG
    qWarning() << "FuncDebug activated";
#endif
    _timeLeft = 0;
    startTimer(60000);
}
Beispiel #3
0
void SocketExternalCommunicator::startListening()
{
    if ( memory_->create(sizeof(qint32))) {
#ifdef Q_OS_UNIX
        // Handle any further termination signals to ensure the
        // QSharedMemory block is deleted even if the process crashes
        setCrashHandler(memory_);
#endif

        *reinterpret_cast<qint32*>(memory_->data()) = version();
        QLocalServer::removeServer(GLOG_SERVICE_NAME);

        connect(server_, SIGNAL(newConnection()), SLOT(onConnection()));
        server_->listen(GLOG_SERVICE_NAME);
    }
}
Beispiel #4
0
int WebServerBaseClass::run_connection(WS_conInst *con)
{
  int s=con->m_serv.run();
  if (s < 0)
  {
    // m_serv.geterrorstr()
    return 1;
  }
  if (s < 2)
  {
    // return 1 if we timed out
    return time(NULL)-con->m_connect_time > m_timeout_s;    
  }
  if (s < 3)
  {
    con->m_pagegen=onConnection(&con->m_serv,con->m_port);
    return 0;
  }
  if (s < 4)
  {
    if (!con->m_pagegen) 
    {
      if (con->m_serv.canKeepAlive()) return -1;

      return !con->m_serv.bytes_inqueue();
    }
    char buf[16384];
    int l=con->m_serv.bytes_cansend();
    if (l > 0)
    {
      if (l > sizeof(buf))l=sizeof(buf);
      l=con->m_pagegen->GetData(buf,l);
      if (l < (con->m_pagegen->IsNonBlocking() ? 0 : 1)) // if nonblocking, this is l < 0, otherwise it's l<1
      {
        if (con->m_serv.canKeepAlive()) return -1;
        return !con->m_serv.bytes_inqueue();
      }
      if (l>0)
        con->m_serv.write_bytes(buf,l);
    }
    return 0;
  }
  if (con->m_serv.canKeepAlive()) return -1;
  return 1; // we're done by this point
}
MainWindow::MainWindow(QWidget* _parent)
  :QMainWindow(_parent),
    m_settings(new Settings()),
    m_ui(new Ui::MainWindow()),
    m_copterCtrl(),
    m_tcpServer(),
    m_tcpConnection(),
    m_accelerometerInputFd(-1),
    m_accelerometerInputNotifier(0),
    m_lastTiltX(0),
    m_lastTiltY(0)
{
  m_ui->setupUi(this);
  const auto s_ctrl_path = m_settings->getControlPath();
  QSharedPointer<CopterMotor> mx1(new CopterMotor(m_settings, s_ctrl_path+"ehrpwm.0/pwm/ehrpwm.0:0/duty_percent", m_ui->motor_x1));
  QSharedPointer<CopterMotor> mx2(new CopterMotor(m_settings, s_ctrl_path+"ehrpwm.0/pwm/ehrpwm.0:1/duty_percent", m_ui->motor_x2));
  QSharedPointer<CopterMotor> my1(new CopterMotor(m_settings, s_ctrl_path+"ehrpwm.1/pwm/ehrpwm.1:0/duty_percent", m_ui->motor_y1));
  QSharedPointer<CopterMotor> my2(new CopterMotor(m_settings, s_ctrl_path+"ehrpwm.1/pwm/ehrpwm.1:1/duty_percent", m_ui->motor_y2));
  QSharedPointer<CopterAxis>  m_axisX(new CopterAxis(mx1, mx2));
  QSharedPointer<CopterAxis>  m_axisY(new CopterAxis(my1, my2));
  m_copterCtrl = new CopterCtrl(m_settings, m_axisX, m_axisY, m_ui->motor_all);

  m_tcpServer.listen(QHostAddress::Any, m_settings->getTcpPort());
  connect(&m_tcpServer, SIGNAL(newConnection()), this, SLOT(onConnection()));

  auto const s_accel_input_path = m_settings->getAccelInputPath();
  m_accelerometerInputFd = ::open(s_accel_input_path.toLatin1().data(), O_SYNC, O_RDONLY);
  if (m_accelerometerInputFd == -1)
    qDebug() << "Cannot open accelerometer input file " << s_accel_input_path << ", reason: " << errno;

  m_accelerometerInputNotifier = new QSocketNotifier(m_accelerometerInputFd, QSocketNotifier::Read, this);
  connect(m_accelerometerInputNotifier, SIGNAL(activated(int)), this, SLOT(onAccelerometerRead()));
  m_accelerometerInputNotifier->setEnabled(true);

  m_copterCtrl->adjustPower(0);

  showFullScreen();
  showMaximized();
}
GraspitProtobufServer::GraspitProtobufServer(unsigned int port_num, QObject * parent ):
    QTcpServer(parent)
{
    connect(this, SIGNAL(newConnection()), this, SLOT(onConnection()));
    this->listen(QHostAddress::Any,port_num);
}