Пример #1
0
CodaDevicePtr SymbianDeviceManager::getCodaDevice(const QString &port)
{
    ensureInitialized();
    QMutexLocker lock(&d->m_devicesLock);
    const int idx = findByPortName(port);
    if (idx == -1) {
        qWarning("Attempt to acquire device '%s' that does not exist.", qPrintable(port));
        if (debug)
            qDebug() << *this;
        return CodaDevicePtr();
    }
    SymbianDevice& device = d->m_devices[idx];
    CodaDevicePtr& devicePtr = device.m_data->codaDevice;
    if (devicePtr.isNull() || !devicePtr->device()->isOpen()) {
        // Check we instanciate in the correct thread - we can't afford to create the CodaDevice (and more specifically, open the VirtualSerialDevice) in a thread that isn't guaranteed to be long-lived.
        // Therefore, if we're not in SymbianDeviceManager's thread, rejig things so it's opened in the main thread
        if (QThread::currentThread() != thread()) {
            // SymbianDeviceManager is owned by the main thread
            d->m_codaPortWaitMutex.lock();
            QWaitCondition waiter;
            QCoreApplication::postEvent(this, new QConstructCodaPortEvent((QEvent::Type)d->m_constructCodaPortEventType, port, &devicePtr, &waiter));
            waiter.wait(&d->m_codaPortWaitMutex);
            // When the wait returns (due to the wakeAll in SymbianDeviceManager::customEvent), the CodaDevice will be fully set up
            d->m_codaPortWaitMutex.unlock();
        } else {
            // We're in the main thread, just set it up directly
            constructCodaPort(devicePtr, port);
        }
    // We still carry on in the case we failed to open so the client can access the IODevice's errorString()
    }
    if (devicePtr->device()->isOpen())
        device.m_data->deviceAcquired++;
    return devicePtr;
}
Пример #2
0
void SymbianDeviceManager::releaseDevice(const QString &port)
{
    const int idx = findByPortName(port);
    if (debug)
        qDebug() << "SymbianDeviceManager::releaseDevice" << port << idx << sender();
    if (idx != -1)
        d->m_devices[idx].releaseDevice();
    else
        qWarning("Attempt to release non-existing device %s.", qPrintable(port));
}
Пример #3
0
bool addToList(const char *portName, PMCVController *drv) {
    if (!PMCVListInitialized) {
        PMCVListInitialized = 1;
        ellInit(&PMCVList);
    } else if (findByPortName(portName) != NULL) {
        fprintf(stderr, "ERROR: Re-using portName=%s\n", portName);
        return false;
    }

    PMCVNode *pNode = (PMCVNode*)calloc(1, sizeof(PMCVNode));
    pNode->portName = epicsStrDup(portName);
    pNode->pController = drv;
    ellAdd(&PMCVList, (ELLNODE*)pNode);
    return true;
}
Пример #4
0
SymbianDeviceManager::TrkDevicePtr
        SymbianDeviceManager::acquireDevice(const QString &port)
{
    ensureInitialized();
    const int idx = findByPortName(port);
    if (idx == -1) {
        qWarning("Attempt to acquire device '%s' that does not exist.", qPrintable(port));
        if (debug)
            qDebug() << *this;
        return TrkDevicePtr();
      }
    const TrkDevicePtr rc = d->m_devices[idx].acquireDevice();
    if (debug)
        qDebug() << "SymbianDeviceManager::acquireDevice" << port << " returns " << !rc.isNull();
    return rc;
}
Пример #5
0
/** Configures an allmotionAxis object.
  * Configuration command, called directly or from iocsh
  * \param[in] portName          The name of the controller's asyn port
  * \param[in] axis              The axis
  * \param[in] movingPollPeriod  The time in ms between polls when any axis is moving
  * \param[in] idlePollPeriod    The time in ms between polls when no axis is moving
  */
extern "C" int allmotionConfigureAxis(const char *portName, int axisNum,
                                      int movingPollPeriod, int idlePollPeriod)
{

  almController *controller;
  if ((controller = findByPortName(portName)) == NULL) {
    return 1;
  }

  allmotionAxis *axis = controller->getAxis(axisNum);
  if (!axis) {
    printf("Bad axis number #%d (axis count = %d)", axisNum, controller->getAxisCount());
    return 1;
  }

  axis->configure();
}
Пример #6
0
/** Update box's comm status and clear errors
  * Configuration command, called directly or from iocsh
  * \param[in] portName             The port name
  */
extern "C" int
PMCVclearBoxErrors(const char* portName)
{
  if (!portName) {
    fprintf(stderr, "%s: must specify PMCV port name\n",
            driverName);
    return asynError;
  }

  PMCVController* controller=findByPortName(portName);
  if (!controller) {
    fprintf(stderr, "%s: invalid port name\n",
            driverName);
    return asynError;
  }

  return controller->clearBoxErrors();
}
Пример #7
0
/** Configures an pmdAxis object.
  * Configuration command, called directly or from iocsh
  * \param[in] portName          The name of the controller's asyn port
  * \param[in] axis              The axis
  * \param[in] encRes            The encoder resolution
  */
extern "C" int pmdConfigureAxis(const char *portName, int axisNum,
                                float enc_res)
{

  pmdController *controller;
  if ((controller = findByPortName(portName)) == NULL) {
    return 1;
  }

  pmdAxis *axis = controller->getAxis(axisNum);
  if (!axis) {
    printf("Bad axis number #%d (axis count = %d)", axisNum, controller->getAxisCount());
    return 1;
  }

  axis->setEncoderResolution(enc_res);
  return 0;
}
Пример #8
0
PMCVAxis *PMCVGetAxis(const char *portName, int axis) {
  if (!portName) {
    fprintf(stderr, "%s: must specify PMCV port name\n",
            driverName);
    return NULL;
  }

  PMCVController* controller=findByPortName(portName);
  if (!controller) {
    fprintf(stderr, "%s: invalid port name\n",
            driverName);
    return NULL;
  }

  PMCVAxis* pAxis=(PMCVAxis*)controller->getAxis(axis);
  if (!pAxis) {
    fprintf(stderr, "%s:%s: Invalid axis number %d (numAxes=%d)\n",
            driverName, portName, axis, controller->getAxisCount());
    return NULL;
  }
  return pAxis;
}
Пример #9
0
void SymbianDeviceManager::setAdditionalInformation(const QString &port, const QString &ai)
{
    const int idx = findByPortName(port);
    if (idx != -1)
        d->m_devices[idx].setAdditionalInformation(ai);
}
Пример #10
0
QString SymbianDeviceManager::friendlyNameForPort(const QString &port) const
{
    const int idx = findByPortName(port);
    return idx == -1 ? QString() : d->m_devices.at(idx).friendlyName();
}