Aufgrund eines Versionsupdates wird GitLab am 17.12. zwischen 9:00 und 9:30 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to a version upgrade, GitLab won't be accessible at 17.12. between 9 and 9:30 a.m.

Initial commit

parents
cmake_minimum_required( VERSION 2.8 )
project( VAPython )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
include( VistaCommon )
vista_use_package( VANet REQUIRED FIND_DEPENDENCIES )
vista_use_package( PythonLibs REQUIRED )
if( ITA_VISTA_BUILD_STATIC )
add_definitions( -DVISTABASE_STATIC -DVISTAMATH_STATIC -DVISTAASPECTS_STATIC -DVISTATOOLS_STATIC -DVISTAINTERPROCCOMM_STATIC )
endif( )
if( NOT BUILD_SHARED_LIBS )
add_definitions( -DVAPYTHON_STATIC -DVABASE_STATIC -DVANET_STATIC )
endif( )
add_definitions( -DPy_NO_ENABLE_SHARED )
add_library( VAPython SHARED "va.cpp" )
target_link_libraries( VAPython ${VISTA_USE_PACKAGE_LIBRARIES} )
# configure
vista_configure_lib( VAPython )
vista_install( VAPython )
set( VACS_INCLUDE_OUTDIR "${CMAKE_CURRENT_SOURCE_DIR}/include" )
vista_create_cmake_configs( VAPython )
vista_create_default_info_file( VAPython )
set_property( TARGET VAPython PROPERTY FOLDER "VA/Bindings" )
Copyright 2015-2017 Institute of Technical Acoustics, RWTH Aachen University
Licensed under the Apache License, Version 2.0 (the "License");
you may not use files of this project except in compliance with the License.
You may obtain a copy of the License at
<http://www.apache.org/licenses/LICENSE-2.0>
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
\ No newline at end of file
## VAPython
VAPython contains is a C++ extension for the Python3 interpreter that provides a (networked) interface to VA.
### License
Copyright 2015-2017 Institute of Technical Acoustics, RWTH Aachen University
Licensed under the Apache License, Version 2.0 (the "License");
you may not use files of this project except in compliance with the License.
You may obtain a copy of the License at
<http://www.apache.org/licenses/LICENSE-2.0>
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
### Quick build guide
Use Pythons *distutils* to build the module that is called `va`. Depending on the version, you will have to install the matching compiler build tools. See the [Python documentation](https://docs.python.org/3.6/library/distutils.html) for more information.
Build VA using CMake with the `ITA_VA_WITH_PYTHON_BINDUNG` option beforehand. This will prepare some paths in the setup configuration.
`python setup.py build`
`python setup.py install --prefix=dist`
Drop the `prefix` argument if you want to integrate the module into your site-packages folder, which might require that you use a command window with administration privileges.
python.exe setup.py build --plat-name=win-amd64 --compiler=msvc
python.exe setup.py install --prefix dist
\ No newline at end of file
from distutils.core import setup, Extension
module1 = Extension('va', sources = ['vasingleton.cpp'])
setup (name = 'va',
version = '1.0',
description = 'Virtual Acoustics singleton interface',
ext_modules = [module1])
\ No newline at end of file
#include <Python.h>
#include <VANetClient.h>
static int g_iVal = 1;
static IVANetClient* g_pVANetClient = nullptr;
PyDoc_STRVAR(va_module_doc,
"connect(server, port) - connect to a VA server at given server and listening port\n"
"disconnect() - disconnect from VA server.");
PyDoc_STRVAR(va_connect__doc__,
"Connect($module, /, server, port)\n"
"--\n"
"\n"
"Connect to a VA server.\n"
"\n"
" server\n"
" Remote server IP.\n"
" port\n"
" TCP/IP listening port, usually 12340.");
static PyObject* va_disconnect_impl(PyObject *module)
{
g_iVal++;
PyObject* pRetVal = PyTuple_New(3);
PyTuple_SetItem(pRetVal, 0, PyLong_FromLong(g_iVal));
PyTuple_SetItem(pRetVal, 1, PyFloat_FromDouble(.4f));
PyTuple_SetItem(pRetVal, 2, PyUnicode_FromString("singed off"));
return pRetVal;
};
static PyObject* va_connect(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
if (!g_pVANetClient)
g_pVANetClient = IVANetClient::Create();
g_pVANetClient->Disconnect();
static const char * const _keywords[] = { "server", "port", NULL };
static _PyArg_Parser _parser = { "Oi:connect", _keywords, 0 };
PyObject* server;
PyObject* port;
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, &server, &port))
{
return PyBool_FromLong(0);
}
char* pcServer = PyUnicode_AsEncodedString
g_pVANetClient->Initialize( )
exit:
return return_value;
}
static PyObject* va_disconnect(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
return va_disconnect_impl(module);
}
static struct PyMethodDef va_methods[] =
{
{ "connect", (PyCFunction)va_connect, METH_FASTCALL, va_connect__doc__ },
{ "disconnect", (PyCFunction)va_disconnect, METH_FASTCALL, va_connect__doc__ },
{ NULL, NULL }
};
static struct PyModuleDef vamoduledef = {
PyModuleDef_HEAD_INIT,
"va",
va_module_doc,
-1,
va_methods,
NULL,
NULL,
NULL,
NULL
};
PyMODINIT_FUNC PyInit_va(void)
{
PyObject *dict;
PyObject *module = PyModule_Create(&vamoduledef);
if (module == NULL)
return NULL;
dict = PyModule_GetDict(module);
/*
ADD_DEFINE(SND_ASYNC);
ADD_DEFINE(SND_NODEFAULT);
ADD_DEFINE(SND_NOSTOP);
ADD_DEFINE(SND_NOWAIT);
ADD_DEFINE(SND_ALIAS);
ADD_DEFINE(SND_FILENAME);
ADD_DEFINE(SND_MEMORY);
ADD_DEFINE(SND_PURGE);
ADD_DEFINE(SND_LOOP);
ADD_DEFINE(SND_APPLICATION);
ADD_DEFINE(MB_OK);
ADD_DEFINE(MB_ICONASTERISK);
ADD_DEFINE(MB_ICONEXCLAMATION);
ADD_DEFINE(MB_ICONHAND);
ADD_DEFINE(MB_ICONQUESTION);
*/
return module;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment