Commit c7a336ef authored by Claes Sjofors's avatar Claes Sjofors Committed by Claes Sjöfors

pwrrt init() function attaching rtdb added

parent dfe9d9fe
...@@ -1864,6 +1864,12 @@ class FetchSev: ...@@ -1864,6 +1864,12 @@ class FetchSev:
filtervalue = self.filterentry.get() filtervalue = self.filterentry.get()
self.server = self.serverentry.get() self.server = self.serverentry.get()
try:
pwrrt.init('sev_analyse')
except RuntimeError as e:
tkMessageBox.showerror("Error", str(e))
return
# Store server to file # Store server to file
try: try:
fp = open(pwrp_tmp + "/sevserver.dat", "w") fp = open(pwrp_tmp + "/sevserver.dat", "w")
...@@ -1999,6 +2005,12 @@ class FetchSev: ...@@ -1999,6 +2005,12 @@ class FetchSev:
intervalvalue = float(self.intervalentry.get()) intervalvalue = float(self.intervalentry.get())
maxvalue = int(self.maxentry.get()) maxvalue = int(self.maxentry.get())
try:
pwrrt.init('sev_analyse')
except RuntimeError as e:
tkMessageBox.showerror("Error", str(e))
return
try: try:
result = pwrrt.getSevItemsDataFrame( self.server, dataoid, dataattr, isobject, result = pwrrt.getSevItemsDataFrame( self.server, dataoid, dataattr, isobject,
fromvalue, tovalue, intervalvalue, maxvalue) fromvalue, tovalue, intervalvalue, maxvalue)
......
...@@ -1827,6 +1827,12 @@ class FetchSev: ...@@ -1827,6 +1827,12 @@ class FetchSev:
except IOError: except IOError:
pass pass
try:
pwrrt.init('sev_eva')
except RuntimeError as e:
tkMessageBox.showerror("Error", str(e))
return
try: try:
self.items = pwrrt.getSevItemList(self.server, filtervalue) self.items = pwrrt.getSevItemList(self.server, filtervalue)
except RuntimeError as e: except RuntimeError as e:
...@@ -2083,6 +2089,13 @@ class FetchSev: ...@@ -2083,6 +2089,13 @@ class FetchSev:
m = m << 1 m = m << 1
maxvalue = int(self.maxentry.get()) maxvalue = int(self.maxentry.get())
print fromvalue, tovalue print fromvalue, tovalue
try:
pwrrt.init('sev_eva')
except RuntimeError as e:
tkMessageBox.showerror("Error", str(e))
return
try: try:
result = pwrrt.getSevEventsDataFrame( self.server, oid, result = pwrrt.getSevEventsDataFrame( self.server, oid,
fromvalue, tovalue, eventtypevalue, fromvalue, tovalue, eventtypevalue,
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "rt_pwr_msg.h" #include "rt_pwr_msg.h"
#include "co_user_msg.h" #include "co_user_msg.h"
static int pwrrt_initialized = 0;
static unsigned int pwrrt_priv = pwr_mPrv_RtRead; static unsigned int pwrrt_priv = pwr_mPrv_RtRead;
static char pwrrt_user[80] = ""; static char pwrrt_user[80] = "";
static sevcli_tCtx pwrrt_scctx = 0; static sevcli_tCtx pwrrt_scctx = 0;
...@@ -628,6 +629,17 @@ quit()\n\ ...@@ -628,6 +629,17 @@ quit()\n\
/* /*
* Doc for static methods * Doc for static methods
*/ */
PyDoc_STRVAR(pwrrt_init_doc,"\
init(name)\n--\n\n\
Attach ProviewR runtime.\n\n\
Arguments\n\
---------\n\
name String\n\
Name of application.\n\n\
Example\n\
-------\n\
pwrrt.init('my_py')\n");
PyDoc_STRVAR(pwrrt_volume_doc,"\ PyDoc_STRVAR(pwrrt_volume_doc,"\
volume(volumeName)\n--\n\n\ volume(volumeName)\n--\n\n\
Get volume\n\n\ Get volume\n\n\
...@@ -2927,6 +2939,14 @@ Appl_init(ApplObject *self, PyObject *args, PyObject *kwds) ...@@ -2927,6 +2939,14 @@ Appl_init(ApplObject *self, PyObject *args, PyObject *kwds)
return -1; return -1;
} }
if (!pwrrt_initialized) {
sts = gdh_Init(name);
if ( EVEN(sts)) {
set_error(sts);
return -1;
}
}
sts = gdh_NameToObjid( applobj, &self->apploid); sts = gdh_NameToObjid( applobj, &self->apploid);
if ( EVEN(sts)) { if ( EVEN(sts)) {
set_error(sts); set_error(sts);
...@@ -3145,6 +3165,24 @@ Appl_log(ApplObject *self, PyObject *args) ...@@ -3145,6 +3165,24 @@ Appl_log(ApplObject *self, PyObject *args)
*/ */
static PyObject *pwrrt_init(PyObject *self, PyObject *args)
{
const char *name;
pwr_tStatus sts;
if (pwrrt_initialized)
Py_RETURN_NONE;
if ( !PyArg_ParseTuple(args, "s", &name))
return NULL;
sts = gdh_Init(name);
if ( EVEN(sts))
return set_error(sts);
pwrrt_initialized = 1;
Py_RETURN_NONE;
}
static PyObject *pwrrt_volume(PyObject *self, PyObject *args) static PyObject *pwrrt_volume(PyObject *self, PyObject *args)
{ {
pwr_tOid oid; pwr_tOid oid;
...@@ -4470,6 +4508,7 @@ static PyObject *pwrrt_getSevEventsDataFrame(PyObject *self, PyObject *args) ...@@ -4470,6 +4508,7 @@ static PyObject *pwrrt_getSevEventsDataFrame(PyObject *self, PyObject *args)
} }
static PyMethodDef PwrrtMethods[] = { static PyMethodDef PwrrtMethods[] = {
{"init", pwrrt_init, METH_VARARGS, pwrrt_init_doc},
{"volume", pwrrt_volume, METH_VARARGS, pwrrt_volume_doc}, {"volume", pwrrt_volume, METH_VARARGS, pwrrt_volume_doc},
{"volumes", pwrrt_volumes, METH_NOARGS, pwrrt_volumes_doc}, {"volumes", pwrrt_volumes, METH_NOARGS, pwrrt_volumes_doc},
{"object", pwrrt_object, METH_VARARGS, pwrrt_object_doc}, {"object", pwrrt_object, METH_VARARGS, pwrrt_object_doc},
...@@ -4524,6 +4563,4 @@ PyMODINIT_FUNC initpwrrt(void) ...@@ -4524,6 +4563,4 @@ PyMODINIT_FUNC initpwrrt(void)
PyModule_AddIntConstant(m, "FRAME_OPTIONS_CONDITION", 1); PyModule_AddIntConstant(m, "FRAME_OPTIONS_CONDITION", 1);
PyDateTime_IMPORT; PyDateTime_IMPORT;
gdh_Init("Python");
} }
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