summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorVasilii Chernov <vchernov@inr.ru>2016-02-12 17:50:57 +0100
committerVasilii Chernov <vchernov@inr.ru>2016-02-12 17:50:57 +0100
commit1b3342649294c6ce99aeb82664a29eac47687ee5 (patch)
treefb34ee89e1edc4dd3e27c2a1416a435192c7ae6b /views
parent55eab7196d0104c71e40136b3b22e9501d234e17 (diff)
downloadpcitool-1b3342649294c6ce99aeb82664a29eac47687ee5.tar.gz
pcitool-1b3342649294c6ce99aeb82664a29eac47687ee5.tar.bz2
pcitool-1b3342649294c6ce99aeb82664a29eac47687ee5.tar.xz
pcitool-1b3342649294c6ce99aeb82664a29eac47687ee5.zip
Move python module init code to transfom view constructor
Update python logger and python exeption messages Change serialization method in create_pcilib_instance set_pcilib functions
Diffstat (limited to 'views')
-rw-r--r--views/transform.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/views/transform.c b/views/transform.c
index ba2f48f..75b95b2 100644
--- a/views/transform.c
+++ b/views/transform.c
@@ -9,6 +9,7 @@
#include "model.h"
#include "transform.h"
#include "py.h"
+#include "error.h"
static int pcilib_transform_view_read(pcilib_t *ctx, pcilib_view_context_t *view_ctx, pcilib_register_value_t regval, pcilib_value_t *val) {
@@ -57,6 +58,34 @@ void pcilib_transform_view_free_description (pcilib_t *ctx, pcilib_view_descript
pcilib_py_free_script(v->module);
}
+pcilib_view_context_t * pcilib_transform_view_init(pcilib_t *ctx, const pcilib_view_description_t *desc)
+{
+ pcilib_transform_view_description_t *v_desc = (pcilib_transform_view_description_t*)desc;
+
+ if(v_desc->module)
+ {
+ pcilib_access_mode_t mode = 0;
+
+ int err = pcilib_py_init_script(ctx, v_desc->module, &mode);
+ if(err)
+ {
+ pcilib_error("Failed init script module (%s) - error %i", v_desc->module, err);
+ return NULL;
+ }
+
+ v_desc->base.mode |= PCILIB_REGISTER_RW;
+ mode |= PCILIB_REGISTER_INCONSISTENT;
+ v_desc->base.mode &= mode;
+ }
+
+ pcilib_view_context_t *view_ctx;
+ view_ctx = (pcilib_view_context_t*)malloc(sizeof(pcilib_view_context_t));
+ if (view_ctx) memset(view_ctx, 0, sizeof(pcilib_view_context_t));
+
+ return view_ctx;
+}
+
+
const pcilib_view_api_description_t pcilib_transform_view_api =
- { PCILIB_VERSION, sizeof(pcilib_transform_view_description_t), NULL, NULL, pcilib_transform_view_free_description, pcilib_transform_view_read, pcilib_transform_view_write };
+ { PCILIB_VERSION, sizeof(pcilib_transform_view_description_t), pcilib_transform_view_init, NULL, pcilib_transform_view_free_description, pcilib_transform_view_read, pcilib_transform_view_write };