Skip navigation links

Package de.spacecontrol.sc.dllwrapper

This package wraps all functions of the SpaceControl DLL (Windows) or the SpaceControl Shared Library (Linux) respectively and makes them accessible for Java, using the Java Native Interface (JNI).

See: Description

Package de.spacecontrol.sc.dllwrapper Description

This package wraps all functions of the SpaceControl DLL (Windows) or the SpaceControl Shared Library (Linux) respectively and makes them accessible for Java, using the Java Native Interface (JNI).

Most that is said about the SC DLL (see its C++ documentation for details) applies for this wrapper. See there in case of ambiguities.

The JNI is rather unhandy with respect to returning function arguments. The functions in the SC DLL have a signature like

    ScStatus scGetSens(int devIdx, int* transSensP, int* rotSensP)
that is, they return a status code of type ScStatus as return value, accept a device index as input and return the interesting data in one or more reference variables. The last is not possible with Java because of the Java calling conventions: That means, there is no way to return the integers in the same way as in the DLL functions. Therefore a set of classes is defined (ScOneInt, ScTwoInts, ScOneBoolean etc.) wrapping the DLL's return parameters needed.
Furthermore the returned status code is replaced by throwing one of the following exceptions: All these exceptions are derived from the base class ScEx.
So, the signature for the function shown above will be in Java
    void scGetSens(int devIdx, ScTwoInts) throws ScEx
The functions are realized as static methods of the ScDllWrapper class. The principle usage is therefore:
public void setSensitivity()
{
        int       devIdx = 0;
        ScTwoInts sens   = new ScTwoInts();

        sens.mVal1 = 10; // translational sensitivity to be set
        sens.mVal1 = 12; // rotational    sensitivity to be set
        try
        {
                scSetSens(devIdx, sens);
                System.out.println("Act. trans. sens.: " + sens.mVal1);
                System.out.println("Act. rot.   sens.: " + sens.mVal2);
        }
        catch (ScWrongDevIdxEx ex)
        {
                System.out.println("Wrong device index transferred.");
        }
        catch (ScParOutOfRangeEx ex)
        {
                System.out.println("Given parameter out of range.");
        }
        catch (ScComErrEx ex)
        {
                System.out.println("Communication error occured.");
        }
}
A minimal application getting data from the cap could be:
package spacecontrollerapitest;

import de.spacecontrol.sc.dllwrapper.ScDllWrapper;
import de.spacecontrol.sc.dllwrapper.ScEx;
import de.spacecontrol.sc.dllwrapper.ScStdData;

public class Main
{
        public static void main(String[] args)
        {
                int       devIdx = 0;
                int       cnt    = 0;
                ScStdData data   = new ScStdData();

                try
                {
                        // connect to the driver:
                        ScDllWrapper.scConnect2(true, null);

                        // fetch data from the device in an endless loop:
                        while (true)
                        {
                                try
                                {
                                        ScDllWrapper.scFetchStdData(devIdx, data);
                                        System.out.println("y: " + data.mY + ", b: " + data.mB);
                                }
                                catch(ScEx ex)
                                {
                                        // scFetchStdData() throws this Exception if no data is 
                                        // received inert 30 ms; this is no error
                                        System.out.println("no data received");
                                }
                                
                                // our endlessness  will last only 100 loop cycles:
                                if (cnt++ == 100)
                                        break;
                        }
                        ScDllWrapper.scDisconnect();
                }
                catch(ScEx ex)
                {
                        System.out.println("scConnect() or scDisconnect() failed.");
                }
        }
}
For a more complete example see the C++ documentation mentioned above. Do not forget to add the library SC_DLL_Wrapper.jar to your project and place the spc_ctrlr_32.dll or spc_ctrlr_64.dll file resp. into your project folder.
Version:
2.8.9
Author:
Friedemann Seebass
Skip navigation links