コード例 #1
0
ファイル: 52-GEL-duck.cpp プロジェクト: jateeq/FYDP
void close(void)
{
    // stop the simulation
    simulationRunning = false;

    // wait for graphics and haptics loops to terminate
    while (!simulationFinished) { cSleepMs(100); }

    // close haptic device
    hapticDevice->close();
}
コード例 #2
0
void close(void)
{
    // stop the simulation
    simulationRunning = false;

    // wait for graphics and haptics loops to terminate
    while (!simulationFinished) { cSleepMs(100); }

    // close haptic device
    tool->stop();
	deltaCtrl.ReleaseDev();
}
コード例 #3
0
ファイル: 01-devices.cpp プロジェクト: jateeq/FYDP
void close(void)
{
    // stop the simulation
    simulationRunning = false;

    // wait for graphics and haptics loops to terminate
    while (!simulationFinished) { cSleepMs(100); }

    // close all haptic devices
    int i=0;
    while (i < numHapticDevices)
    {
        hapticDevices[i]->close();
        i++;
    }
}
コード例 #4
0
void close(void)
{
    // stop the simulation
    simulationRunning = false;

    // wait for graphics and haptics loops to terminate
    while (!simulationFinished) { cSleepMs(100); }

    // close haptic device
    tool->stop();
	// my device close**************************MINE
	memset(dF,0,sizeof(dF));
	memset(dT,0,sizeof(dT));

	//deltaCtrl.SetFGetPosStatues(dF,dPos,statu,dT,blOutRange);	// clear force
	deltaCtrl.SetTorqueGetPosStatus(dT,nErrCode);	// clear the force
	deltaCtrl.ReleaseDev();
}
コード例 #5
0
//===========================================================================
void cHapticDeviceHandler::update()
{
    // temp variables
    int index, count;
    cGenericHapticDevice* device;

    // clear current list of devices
    m_numDevices = 0;
    for (unsigned int i=0; i<C_MAX_HAPTIC_DEVICES; i++)
    {
        if (m_devices[i] != NULL)
        {
            delete m_devices[i];
        }
        m_devices[i] = NULL;
    }

    //-----------------------------------------------------------------------
    // search for Force Dimension devices
    //-----------------------------------------------------------------------
    #if defined(C_ENABLE_DELTA_DEVICE_SUPPORT)

    // reset index number
    index = 0;

    // check for how many devices of this type that are available
    // and store the first one if available
    device = new cDeltaDevice(index);
    count = device->getNumDevices();
    if (count > 0)
    {
        m_devices[m_numDevices] = device;
        m_numDevices++;
    }
    else
    {
        delete device;
    }

    //  open all remaining devices
    for (int i=1; i<count; i++)
    {
        index++;
        device = new cDeltaDevice(index);
        m_devices[m_numDevices] = device;
        m_numDevices++;
    }

    #endif

    //-----------------------------------------------------------------------
    // search for Novint Falcon device
    //-----------------------------------------------------------------------
    #if defined(C_ENABLE_FALCON_DEVICE_SUPPORT)

    // reset index number
    index = 0;

    // create a first device of this class
    device = new cFalconDevice();

    // check for how many devices of this type that are available
    count = device->getNumDevices();

    // if there are one or more devices available, then store them in the device table
    if (count > 0)
    {
        // store first device
        m_devices[m_numDevices] = device;
        device->open();
        m_numDevices++;

        // search for other devices
        if (count > 1)
        {
            for (int i=1; i<count; i++)
            {
                index++;
                device = new cFalconDevice(index);
                device->open();
                m_devices[m_numDevices] = device;
                m_numDevices++;
            }
        }
    }
    else
    {
        delete device;
    }

    #endif


    //-----------------------------------------------------------------------
    // search for Sensable Technologies devices
    //-----------------------------------------------------------------------
    #if defined(C_ENABLE_PHANTOM_DEVICE_SUPPORT)

    // reset index number
    index = 0;

    // create a first device of this class
    device = new cPhantomDevice(index);

    // check for how many devices of this type that are available
    count = device->getNumDevices();

    // if there are one or more devices available, then store them in the device table
    if (count > 0)
    {
        // store first device
        m_devices[m_numDevices] = device;
        m_numDevices++;

        // search for other devices
        if (count > 1)
        {
            for (int i=1; i<count; i++)
            {
                index++;
                device = new cPhantomDevice(index);
                m_devices[m_numDevices] = device;
                m_numDevices++;
            }
        }
    }
    else
    {
        delete device;
    }

    #endif

    //-----------------------------------------------------------------------
    // search for MyCustom device
    //-----------------------------------------------------------------------
    #if defined(C_ENABLE_CUSTOM_DEVICE_SUPPORT)

    // reset index number
    index = 0;

    // create a first device of this class
    device = new cMyCustomDevice(index);

    // check for how many devices of this type that are available
    count = device->getNumDevices();

    // if there are one or more devices available, then store them in the device table
    if (count > 0)
    {
        // store first device
        m_devices[m_numDevices] = device;
        m_numDevices++;

        // search for other devices
        if (count > 1)
        {
            for (int i=1; i<count; i++)
            {
                index++;
                device = new cMyCustomDevice(index);
                m_devices[m_numDevices] = device;
                m_numDevices++;
            }
        }
    }
    else
    {
        delete device;
    }

    #endif

    //-----------------------------------------------------------------------
    // search for CHAI3D Virtual Device
    // Note:
    // Virtual devices should always be listed last. The desired behavior
    // is that an application first searches for physical devices. If none
    // are found, it may launch a virtual device
    //-----------------------------------------------------------------------
    #if defined(C_ENABLE_VIRTUAL_DEVICE_SUPPORT)

    // reset index number
    index = 0;

    // create a first device of this class
    device = new cVirtualDevice();

    // check for how many devices of this type that are available
    count = device->getNumDevices();

    // if there are one or more devices available, then store it in the device table
    if (count > 0)
    {
        // store first device
        m_devices[m_numDevices] = device;
        m_numDevices++;
    }

    // if no devices have been found then we try to launch a virtual haptic device
    else if (m_numDevices == 0)
    {
        // delete previous device
        delete device;

        // we try to launch the virtual device.
        spawnlp(_P_NOWAIT, "VirtualDevice.exe", "VirtualDevice.exe", NULL);
        cSleepMs(750);

        // create again a first device of this class
        device = new cVirtualDevice();

        // check for how many devices of this type that are available
        count = device->getNumDevices();

        // if there are one or more devices available, then store it in the device table
        if (count > 0)
        {
            // store first device
            m_devices[m_numDevices] = device;
            m_numDevices++;
        }
    }
    #endif
}