Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
VAPython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Institute of Technical Acoustics (ITA)
VAPython
Commits
d0999363
Commit
d0999363
authored
Aug 22, 2017
by
Dipl.-Ing. Jonas Stienen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trying to parse arguments 2
parent
a9b97194
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
18 deletions
+31
-18
src/vasingletonmethods.hpp
src/vasingletonmethods.hpp
+31
-18
No files found.
src/vasingletonmethods.hpp
View file @
d0999363
...
...
@@ -4,14 +4,15 @@
#include <VAException.h>
#include <string.h>
// If you want to extend the va Python
module
interface, also add
// If you want to extend the va Python
pSelf
interface, also add
// the function to the va_methods table in vasingleton.cpp - otherwise they will not show up.
// Documentation goes into vasingletondoc.hpp
static
IVANetClient
*
g_pVANetClient
=
nullptr
;
//!< Static pointer to VANetClient instance
static
PyObject
*
g_pVAError
=
nullptr
;
//!< Static pointer to error instance
//! Helper for API dev
static
PyObject
*
va_not_implemented
(
PyObject
*
module
,
PyObject
**
args
,
Py_ssize_t
nargs
,
PyObject
*
kwn
ames
)
static
PyObject
*
va_not_implemented
(
PyObject
*
pSelf
,
PyObject
**
ppArgs
,
Py_ssize_t
nArgs
,
PyObject
*
pKeywordN
ames
)
{
VA_EXCEPT_NOT_IMPLEMENTED
;
return
NULL
;
...
...
@@ -27,39 +28,51 @@ static void RequireCoreAvailable()
VA_EXCEPT2
(
CVAException
::
NETWORK_ERROR
,
"VA client available, but access to VA interface failed. Please reconnect."
);
}
static
PyObject
*
va_connect
(
PyObject
*
self
,
PyObject
*
arg
s
)
static
PyObject
*
va_connect
(
PyObject
*
pSelf
,
PyObject
**
ppArgs
,
Py_ssize_t
nArgs
,
PyObject
*
pKeywordName
s
)
{
if
(
!
g_pVANetClient
)
g_pVANetClient
=
IVANetClient
::
Create
();
if
(
g_pVANetClient
->
IsConnected
()
)
{
PyErr_Warn
(
pSelf
,
"Was still connected, forced disconnect."
);
g_pVANetClient
->
Disconnect
();
const
char
*
pcServerIP
=
nullptr
;
}
static
const
char
*
const
_keywords
[]
=
{
"server"
,
"port"
,
NULL
};
static
_PyArg_Parser
_parser
=
{
"Oi:connect"
,
_keywords
,
0
};
PyObject
*
pServer
;
PyObject
*
pPort
;
if
(
!
_PyArg_ParseStack
(
ppArgs
,
nArgs
,
pKeywordNames
,
&
_parser
,
&
pServer
,
&
pPort
)
)
return
PyBool_FromLong
(
0
);
std
::
string
sServerIP
=
"localhost"
;
if
(
PyArg_ParseTuple
(
args
,
"s"
,
&
pcServerIP
)
)
char
*
pcServerIP
=
nullptr
;
if
(
PyArg_ParseTuple
(
pPort
,
"i"
,
&
pcServerIP
)
)
sServerIP
=
std
::
string
(
pcServerIP
);
int
iServerPort
=
-
1
;
if
(
!
PyArg_ParseTuple
(
args
,
"i"
,
&
iServerPort
))
iServerPort
=
12340
;
int
iServerPort
=
12340
;
int
*
piServerPort
=
nullptr
;
if
(
PyArg_ParseTuple
(
pPort
,
"i"
,
&
piServerPort
)
)
iServerPort
=
*
piServerPort
;
if
(
IVANetClient
::
VA_NO_ERROR
==
g_pVANetClient
->
Initialize
(
sServerIP
,
iServerPort
)
)
return
PyBool_FromLong
(
1
);
PyErr_SetString
(
PyExc_ConnectionError
,
std
::
string
(
"Could not connect to "
+
sServerIP
+
" on "
+
std
::
to_string
(
(
long
)
iServerPort
)
).
c_str
()
);
return
NULL
;
}
static
PyObject
*
va_disconnect
(
PyObject
*
module
,
PyObject
**
args
,
Py_ssize_t
nargs
,
PyObject
*
kwn
ames
)
static
PyObject
*
va_disconnect
(
PyObject
*
pSelf
,
PyObject
**
ppArgs
,
Py_ssize_t
nArgs
,
PyObject
*
pKeywordN
ames
)
{
if
(
g_pVANetClient
)
g_pVANetClient
->
Disconnect
();
return
PyBool_FromLong
(
1
);
}
static
PyObject
*
va_is_connected
(
PyObject
*
module
,
PyObject
**
args
,
Py_ssize_t
nargs
,
PyObject
*
kwn
ames
)
static
PyObject
*
va_is_connected
(
PyObject
*
pSelf
,
PyObject
**
ppArgs
,
Py_ssize_t
nArgs
,
PyObject
*
pKeywordN
ames
)
{
if
(
!
g_pVANetClient
)
return
PyBool_FromLong
(
0
);
...
...
@@ -67,7 +80,7 @@ static PyObject* va_is_connected( PyObject *module, PyObject **args, Py_ssize_t
return
PyBool_FromLong
(
g_pVANetClient
->
IsConnected
()
);
}
static
PyObject
*
va_reset
(
PyObject
*
module
,
PyObject
**
args
,
Py_ssize_t
nargs
,
PyObject
*
kwn
ames
)
static
PyObject
*
va_reset
(
PyObject
*
pSelf
,
PyObject
**
ppArgs
,
Py_ssize_t
nArgs
,
PyObject
*
pKeywordN
ames
)
{
RequireCoreAvailable
();
...
...
@@ -76,7 +89,7 @@ static PyObject* va_reset( PyObject *module, PyObject **args, Py_ssize_t nargs,
return
PyBool_FromLong
(
1
);
}
static
PyObject
*
va_enumerate_modules
(
PyObject
*
module
,
PyObject
**
args
,
Py_ssize_t
nargs
,
PyObject
*
kwn
ames
)
static
PyObject
*
va_enumerate_modules
(
PyObject
*
pSelf
,
PyObject
**
ppArgs
,
Py_ssize_t
nArgs
,
PyObject
*
pKeywordN
ames
)
{
RequireCoreAvailable
();
...
...
@@ -85,7 +98,7 @@ static PyObject* va_enumerate_modules( PyObject *module, PyObject **args, Py_ssi
return
NULL
;
}
static
PyObject
*
va_call_module
(
PyObject
*
module
,
PyObject
**
args
,
Py_ssize_t
nargs
,
PyObject
*
kwn
ames
)
static
PyObject
*
va_call_module
(
PyObject
*
pSelf
,
PyObject
**
ppArgs
,
Py_ssize_t
nArgs
,
PyObject
*
pKeywordN
ames
)
{
RequireCoreAvailable
();
...
...
@@ -94,7 +107,7 @@ static PyObject* va_call_module( PyObject *module, PyObject **args, Py_ssize_t n
return
NULL
;
}
static
PyObject
*
va_add_search_path
(
PyObject
*
module
,
PyObject
**
args
,
Py_ssize_t
nargs
,
PyObject
*
kwn
ames
)
static
PyObject
*
va_add_search_path
(
PyObject
*
pSelf
,
PyObject
**
ppArgs
,
Py_ssize_t
nArgs
,
PyObject
*
pKeywordN
ames
)
{
RequireCoreAvailable
();
...
...
@@ -103,7 +116,7 @@ static PyObject* va_add_search_path( PyObject *module, PyObject **args, Py_ssize
return
NULL
;
}
static
PyObject
*
va_create_listener
(
PyObject
*
module
,
PyObject
**
args
,
Py_ssize_t
nargs
,
PyObject
*
kwn
ames
)
static
PyObject
*
va_create_listener
(
PyObject
*
pSelf
,
PyObject
**
ppArgs
,
Py_ssize_t
nArgs
,
PyObject
*
pKeywordN
ames
)
{
RequireCoreAvailable
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment