Saving stage

parent 88524d79
......@@ -29,7 +29,11 @@ set( BATCH_SCRIPT_EXTENSION "bat" )
if( NOT WIN32 )
set( BATCH_SCRIPT_EXTENSION "sh" )
endif( )
add_custom_command( TARGET VAPython POST_BUILD COMMAND "distutils_build.${BATCH_SCRIPT_EXTENSION}" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Running distutils" VERBATIM )
set( BATCH_SCRIPT_TYPE distutils_build_static )
if( BUILD_SHARED_LIBS )
set( BATCH_SCRIPT_TYPE distutils_build_shared )
endif( )
add_custom_command( TARGET VAPython POST_BUILD COMMAND "${BATCH_SCRIPT_TYPE}.${BATCH_SCRIPT_EXTENSION}" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Running distutils" VERBATIM )
# configure
#vista_configure_lib( VAPython )
......
python.exe setup.py clean
python.exe setup.py build --force
python.exe setup.py install --prefix dist
python.exe setup.py sdist --formats=zip
rem later:
rem python.exe setup.py bdist_wininst
python.exe setup.py check
......@@ -14,7 +14,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {
"scrolled": false
},
......@@ -36,9 +36,21 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "ImportError",
"evalue": "DLL load failed: Das angegebene Modul wurde nicht gefunden.",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mImportError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-3-9508d0d3eded>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0mva\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mImportError\u001b[0m: DLL load failed: Das angegebene Modul wurde nicht gefunden."
]
}
],
"source": [
"import va"
]
......@@ -60,7 +72,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"connection_status = va.connect()"
......@@ -75,17 +89,9 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"VA connection ready!\n"
]
}
],
"outputs": [],
"source": [
"connected = va.is_connected()\n",
"if connected :\n",
......@@ -103,8 +109,10 @@
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"if not connected :\n",
......@@ -115,15 +123,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"working directory: D:\\Users\\stienen\\dev\\VA\\VAPython\\examples\\jupyter\n"
]
}
],
"outputs": [],
"source": [
"import os\n",
"current_working_dir = os.getcwd()\n",
......@@ -140,11 +140,32 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"va.add_search_path( current_working_dir )"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"vamods = va.enumerate_modules()\n",
"print( vamods )"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
......@@ -152,18 +173,6 @@
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.2"
}
},
"nbformat": 4,
......
......@@ -4,7 +4,7 @@ module1 = Extension('va',
define_macros = [('VA_PYTHON_VERSION_MAJOR', '2017'), ('VA_PYTHON_VERSION_MINOR', 'c'), ('VABASE_STATIC', 1), ('VANET_STATIC', 1), ('VISTABASE_STATIC', 1), ('VISTAINTERPROCCOMM_STATIC', 1), ('VISTAASPECTS_STATIC',1)],
include_dirs = ['../VABase/include','../VANet/include'],
libraries = ['VABase', 'VANet', 'VistaBase', 'VistaAspects', 'VistaInterProcComm', 'winmm', 'ws2_32' ],
library_dirs = ['../build_win32-x64.vc14_static/lib','../../ViSTA/build_static_win32-x64.vc14/lib'],
library_dirs = ['../build_win32-x64.vc14/lib','../../ViSTA/build_win32-x64.vc14/lib'],
sources = ['src/vasingleton.cpp'] )
setup (name = 'va',
......
......@@ -49,9 +49,9 @@ static struct PyMethodDef va_methods[] =
{ "set_signal_source_parameters", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "get_signal_source_parameters", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "is_scene_locked", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "lock_scene", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "unlock_scene", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "is_scene_locked", ( PyCFunction ) va_is_scene_locked, METH_FASTCALL, va_no_doc },
{ "lock_scene", ( PyCFunction ) va_lock_scene, METH_FASTCALL, va_no_doc },
{ "unlock_scene", ( PyCFunction ) va_unlock_scene, METH_FASTCALL, va_no_doc },
{ "get_sound_source_ids", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "create_sound_source", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
......
#include <Python.h>
#include <VANetClient.h>
#include <VACore.h>
#include <VAStruct.h>
#include <VAException.h>
#include <string.h>
......@@ -32,6 +33,21 @@ static void RequireCoreAvailable()
VA_EXCEPT2(CVAException::NETWORK_ERROR, "VA client available, but access to VA interface failed. Please reconnect.");
};
//! Helper to convert recursively from VAStruct to Python dict
PyObject* ConvertVAStructToPythonDict( const CVAStruct& oInStruct )
{
return PyLong_FromLong( -1 );
};
//! Helper to convert recursively from Python dict to VAStruct
CVAStruct ConvertPythonDictToVAStruct( PyObject* pInDict )
{
return CVAStruct();
};
// ------------------------------- Python module extension methods
static PyObject* va_connect(PyObject* pSelf, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames)
{
if (!g_pVANetClient)
......@@ -100,12 +116,12 @@ static PyObject* va_enumerate_modules(PyObject* pSelf, PyObject** ppArgs, Py_ssi
std::vector< CVAModuleInfo > voModuleInfos;
g_pVANetClient->GetCoreInstance()->EnumerateModules(voModuleInfos);
PyObject *pModuleList = PyList_New(voModuleInfos.size());
PyObject* pModuleList = PyList_New(voModuleInfos.size());
for (size_t i = 0; i < voModuleInfos.size(); i++)
{
CVAModuleInfo& oModule(voModuleInfos[i]);
PyObject* pModuleInfo = Py_BuildValue("{s:i,s:s,s:s}", "index", i, "name", oModule.sName, "description", oModule.sDesc);
PyObject* pModuleInfo = Py_BuildValue("{s:i,s:s,s:s}", "index", i, "name", oModule.sName.c_str(), "description", oModule.sDesc.c_str() );
PyList_SetItem(pModuleList, i, pModuleInfo); // steals reference
}
......@@ -117,7 +133,23 @@ static PyObject* va_enumerate_modules(PyObject* pSelf, PyObject** ppArgs, Py_ssi
static PyObject* va_call_module(PyObject* pSelf, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames)
{
VAPY_REQUIRE_CONN_TRY;
VA_EXCEPT_NOT_IMPLEMENTED;
static const char * const _keywords[] = { "module_name", "arguments", NULL };
static _PyArg_Parser _parser = { "so:call_module", _keywords, 0 };
char* pcModuleName = nullptr;
PyObject* pArguments = nullptr;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcModuleName, &pArguments ) )
return NULL;
std::string sModuleName = std::string( pcModuleName );
CVAStruct oArgs = ConvertPythonDictToVAStruct( pArguments );
CVAStruct oReturn;
g_pVANetClient->GetCoreInstance()->CallModule( sModuleName, oArgs, oReturn );
return ConvertVAStructToPythonDict( oReturn );
VAPY_CATCH_RETURN;
};
......@@ -147,3 +179,25 @@ static PyObject* va_create_listener(PyObject* pSelf, PyObject** ppArgs, Py_ssize
VAPY_CATCH_RETURN;
};
static PyObject* va_is_scene_locked( PyObject* pSelf, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY;
return PyLong_FromLong( g_pVANetClient->GetCoreInstance()->IsSceneLocked() );
VAPY_CATCH_RETURN;
};
static PyObject* va_lock_scene( PyObject* pSelf, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY
g_pVANetClient->GetCoreInstance()->LockScene();
return PyLong_FromLong( 1 );
VAPY_CATCH_RETURN;
};
static PyObject* va_unlock_scene( PyObject* pSelf, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY;
return PyLong_FromLong( g_pVANetClient->GetCoreInstance()->UnlockScene() );
VAPY_CATCH_RETURN;
};
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