6.1.7. A short description of the work with supported by programming languages

Library usage can be examined from test application testapp. Non-C languages are supported because library supports stdcall calling convention and so can be used with a variety of languages.

C test project is located at “examples/test_C/testapp_C” directory, C# test project - at “examples/test_CSharp”, VB.NET - “examples/test_VBNET”, Delphi 6 - “examples/test_Delphi”, sample bindings for MATLAB - “examples/test_MATLAB”, for Java - “examples/test_Java”, for Python - “examples/test_Python”. Development kit also contains precompiled examples: testapp and testappeasy as 32 and 64-bit applications for Windows and 64-bit application for OSX, test_CSharp, test_VBNET, test_Delphi - 32-bit only, test_Java is architecture-independent, test_MATLAB and test_Python are runtime-interpreted. Also the programming guide can be downloaded from this link.

Note

SDK requires Microsoft Visual C++ Redistributable Package 2013 (provided with SDK - vcredist_x86 or vcredist_x64)

6.1.7.1. Visual C++

Testapp can be built using testapp.sln. Library must be compiled with MS Visual C++ too, mingw-library isn’t supported. Make sure that Microsoft Visual C++ Redistributable Package 2013 is installed.

Open solution examples/testapp/testapp.sln, build and run from the IDE.

6.1.7.2. .NET (C# and Visual Basic)

Wrapper assembly for libximc.dll is wrappers/csharp/ximcnet.dll. It is provided with two different architectures and depends on .NET 2.0.

Test .NET applications for Visual Studio 2013 is located at testcs (for C#) and testvbnet (for VB.NET) respectively. Open solutions and build.

6.1.7.3. Delphi

Wrapper for libximc.dll is a unit wrappers/delphi/ximc.pas Console test application for is located at “testdelphi”. Tested with Delphi 6 and only 32-bit version. Just compile, place DLL near the executable and run program.

6.1.7.4. Matlab

Sample MATLAB program testximc.m is provided at the directory examples/testmatlab.

Before launch:

On OS X: copy ximc/macosx/libximc.framework, ximc/macosx/ wrappers/ximcm.h, ximc/ximc.h to the directory examples/ matlab. Install XCode compatible with Matlab.

On Linux: install libximc*deb and libximc-dev*dev of target architecture. Then copy ximc/macosx/wrappers/ximcm.h to the directory examples/matlab. Install gcc compatible with Matlab.

For XCode and gcc version compability check document or similar.

On Windows before the start nothing needs to be done. Change current directory in the MATLAB to the examples/matlab. Then launch in MATLAB prompt:

6.1.7.5. Java

How to run example on Linux. Navigate to ximc-2.x.x./examples/testjava/compiled/ and run:

$ java -cp /usr/share/java/libjximc.jar:testjava.jar ru.ximc.TestJava

How to run example on Windows or Mac. Navigate to ximc-2.x.x./ examples/testjava/compiled/. Copy contents of ximc-2.x.x/ximc/win64 or ximc-2.x.x/ximc/macosx accordingly to the current directory. Then run:

$ java -classpath libjximc.jar -classpath testjava.jar ru.ximc.TestJava

How to modify and recompile an example. Navigate to examples/ testjava/compiled. Sources are embedded in a testjava.jar. Extract them:

$ jar xvf testjava.jar ru META-INF

Then rebuild sources:

$ javac -classpath /usr/share/java/libjximc.jar -Xlint ru/ximc/TestJava.java

or for windows or mac:

$ javac -classpath libjximc.jar -Xlint ru/ximc/TestJava.java

Then build a jar:

$ jar cmf META-INF/MANIFEST.MF testjava.jar ru

6.1.7.6. Python

Change current directory to the examples/test_Python/xxxxtest.

On Linux: you may need to set LD_LIBRARY_PATH so Python can locate libraries with RPATH. For example, you may need:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`

On Windows and MacOS nothing needs to be done before the start. Launch Python 2 or Python 3:

python xxxx.py

Note

Generic logging facility. If you want to turn on file logging, you should run the program that uses libximc library with the “XILOG” environment variable set to desired file name. This file will be opened for writing on the first log event and will be closed when the program which uses libximc terminates. Data which is sent to/received from the controller is logged along with port open and close events.

Note

Required permissions: libximc generally does not require special permissions to work, it only needs read/write access to USB-serial ports on the system. An exception to this rule is a Windows-only “fix_usbser_sys()” function - it needs elevation and will produce null result if run as a regular user.

Note

C-profiles. C-profiles are header files distributed with the libximc library. They enable one to set all controller settings for any of the supported stages with a single function call in a C/C++ program. You may see how to use C-profiles in “testcprofile” example directory.

6.1.7.7. Python (Jupyter Notebook)

We have added Jupyter Notebook support to simplify Python programming.
The notebook below shows how to work with 8SMC5 Standa Motor Controllers over the libximc python binding.

In case you are not familiar with Jupyter Notebooks check official documentation.

Open in Colab
Open in HTML format

Note

By default this notebook uses virtual controller. So you don’t need any real hardware. But if you have one, you can also test it with this notebook.