فهرست منبع

Add support for setting register value to script transfrom. Add set_property and get_property functions to pcipywrap. Cleaning cmakelists from unused dependencies

Vasilii Chernov 8 سال پیش
والد
کامیت
e10e102b8b
10فایلهای تغییر یافته به همراه298 افزوده شده و 108 حذف شده
  1. 4 4
      pcilib/CMakeLists.txt
  2. 163 47
      pcilib/pcipywrap.c
  3. 3 1
      pcilib/pcipywrap.i
  4. 45 15
      pcilib/xml.c
  5. 70 21
      views/script.c
  6. 0 1
      xml/model.xsd
  7. 0 1
      xml/references.xsd
  8. 7 3
      xml/test_pywrap/props.xml
  9. 6 5
      xml/test_pywrap/test_prop2.py
  10. 0 10
      xml/types.xsd

+ 4 - 4
pcilib/CMakeLists.txt

@@ -8,8 +8,8 @@ include_directories(
     ${UTHASH_INCLUDE_DIRS}
 )
 
-set(HEADERS pcilib.h pci.h datacpy.h memcpy.h pagecpy.h cpu.h timing.h export.h value.h bar.h fifo.h model.h bank.h register.h view.h property.h unit.h xml.h py.h kmem.h irq.h locking.h lock.h dma.h event.h plugin.h tools.h error.h debug.h env.h version.h config.h)
-add_library(pcilib SHARED pci.c datacpy.c memcpy.c pagecpy.c cpu.c timing.c export.c value.c bar.c fifo.c model.c bank.c register.c view.c unit.c property.c xml.c py.c kmem.c irq.c locking.c lock.c dma.c event.c plugin.c tools.c error.c debug.c env.c )
+set(HEADERS pcilib.h pci.h pcipywrap.h datacpy.h memcpy.h pagecpy.h cpu.h timing.h export.h value.h bar.h fifo.h model.h bank.h register.h view.h property.h unit.h xml.h py.h kmem.h irq.h locking.h lock.h dma.h event.h plugin.h tools.h error.h debug.h env.h version.h config.h)
+add_library(pcilib SHARED pci.c pcipywrap.c datacpy.c memcpy.c pagecpy.c cpu.c timing.c export.c value.c bar.c fifo.c model.c bank.c register.c view.c unit.c property.c xml.c py.c kmem.c irq.c locking.c lock.c dma.c event.c plugin.c tools.c error.c debug.c env.c )
 target_link_libraries(pcilib dma protocols views ${CMAKE_THREAD_LIBS_INIT} ${UFODECODE_LIBRARIES} ${CMAKE_DL_LIBS} ${EXTRA_SYSTEM_LIBS} ${LIBXML2_LIBRARIES} ${PYTHON_LIBRARIES})
 add_dependencies(pcilib dma protocols views)
 
@@ -22,8 +22,8 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
 SET(CMAKE_SWIG_FLAGS "")
 
 SET_SOURCE_FILES_PROPERTIES(pcipywrap.i PROPERTIES SWIG_FLAGS "-includeall")
-SWIG_ADD_MODULE(pcipywrap python pcipywrap.i pcipywrap.c pci.c datacpy.c memcpy.c pagecpy.c cpu.c timing.c export.c value.c bar.c fifo.c model.c bank.c register.c view.c unit.c property.c xml.c py.c kmem.c irq.c locking.c lock.c dma.c event.c plugin.c tools.c error.c debug.c env.c)
-SWIG_LINK_LIBRARIES(pcipywrap ${PYTHON_LIBRARIES} dma protocols views ${CMAKE_THREAD_LIBS_INIT} ${UFODECODE_LIBRARIES} ${CMAKE_DL_LIBS} ${EXTRA_SYSTEM_LIBS} ${LIBXML2_LIBRARIES})
+SWIG_ADD_MODULE(pcipywrap python pcipywrap.i)
+SWIG_LINK_LIBRARIES(pcipywrap ${PYTHON_LIBRARIES} pcilib)
 
 install(TARGETS pcilib
     LIBRARY DESTINATION lib${LIB_SUFFIX}

+ 163 - 47
pcilib/pcipywrap.c

@@ -1,7 +1,6 @@
-#include "pcilib.h"
-#include <Python.h>
 #include "pci.h"
 #include "error.h"
+#include "pcipywrap.h"
 
 /*!
  * \brief Global pointer to pcilib_t context.
@@ -24,16 +23,46 @@ PyObject* __createPcilibInstance(const char *fpga_device, const char *model)
     return PyByteArray_FromStringAndSize((const char*)&ctx, sizeof(pcilib_t*));
 }
 
+/*!
+ * \brief Sets python exeption text. Function interface same as printf.
+ */
+void setPyExeptionText(const char* msg, ...)
+{
+	char *buf;
+	size_t sz;
+	
+	va_list vl, vl_copy;
+    va_start(vl, msg);
+	va_copy(vl_copy, vl);
+	
+	sz = vsnprintf(NULL, 0, msg, vl);
+	buf = (char *)malloc(sz + 1);
+	
+	if(!buf)
+	{
+		PyErr_SetString(PyExc_Exception, "Memory error");
+		return;
+	}
+
+	vsnprintf(buf, sz+1, msg, vl_copy);
+	va_end(vl_copy);
+	va_end(vl);
+	
+	PyErr_SetString(PyExc_Exception, buf);
+	free(buf);
+}
+
 /*!
  * \brief Sets pcilib context to wraper.
  * \param[in] addr Pointer to pcilib_t, serialized to bytearray
+ * \return true, serialized to PyObject, NULL with exeption text, if failed.
  */
-void __setPcilib(PyObject* addr)
+PyObject* __setPcilib(PyObject* addr)
 {
 	if(!PyByteArray_Check(addr))
 	{
-		PyErr_SetString(PyExc_Exception, "Incorrect addr type. Only bytearray is allowed");
-		return NULL;
+		setPyExeptionText(PyExc_Exception, "Incorrect addr type. Only bytearray is allowed");
+		return;
 	}
 	
 	//deserializing adress
@@ -44,8 +73,82 @@ void __setPcilib(PyObject* addr)
 		((char*)&__ctx)[i] = pAddr[i];
 
 	free(pAddr);
+	
+	return PyInt_FromLong((long)1);
 }
 
+PyObject* pcilib_convert_val_to_pyobject(pcilib_t* ctx, pcilib_value_t *val, void (*errstream)(const char* msg, ...))
+{
+	int err;
+	
+	switch(val->type)
+	{
+		case PCILIB_TYPE_INVALID:
+            errstream("Invalid register output type (PCILIB_TYPE_INVALID)");
+			return NULL;
+			
+		case PCILIB_TYPE_STRING:
+            errstream("Invalid register output type (PCILIB_TYPE_STRING)");
+			return NULL;
+		
+		case PCILIB_TYPE_LONG:
+		{
+			long ret;
+			ret = pcilib_get_value_as_int(__ctx, val, &err);
+			
+			if(err)
+			{
+                errstream("Failed: pcilib_get_value_as_int (%i)", err);
+				return NULL;
+			}
+			return PyInt_FromLong((long) ret);
+		}
+		
+		case PCILIB_TYPE_DOUBLE:
+		{
+			double ret;
+			ret = pcilib_get_value_as_float(__ctx, val, &err);
+			
+			if(err)
+			{
+                errstream("Failed: pcilib_get_value_as_int (%i)", err);
+				return NULL;
+			}
+			return PyFloat_FromDouble((double) ret);
+		}
+		
+		default:
+            errstream("Invalid register output type (unknown)");
+			return NULL;
+	}
+}
+
+int pcilib_convert_pyobject_to_val(pcilib_t* ctx, PyObject* pyVal, pcilib_value_t *val)
+{
+	int err;
+	
+    if(PyInt_Check(pyVal))
+    {
+        err = pcilib_set_value_from_int(ctx, val, PyInt_AsLong(pyVal));
+    }
+    else
+        if(PyFloat_Check(pyVal))
+            err = pcilib_set_value_from_float(ctx, val, PyFloat_AsDouble(pyVal));
+        else
+            if(PyString_Check(pyVal))
+                err = pcilib_set_value_from_static_string(ctx, val, PyString_AsString(pyVal));
+                else
+                {
+                    pcilib_error("Invalid input. Input type should be int, float or string.");
+                    return PCILIB_ERROR_NOTSUPPORTED;
+                }
+    if(err)
+        return err;
+        
+    return 0;
+}
+
+
 /*!
  * \brief Reads register value.
  * \param[in] regname the name of the register
@@ -53,10 +156,10 @@ void __setPcilib(PyObject* addr)
  * \return register value, can be integer or float type
  */
 PyObject* read_register(const char *regname, const char *bank)
-{	
+{
 	if(!__ctx)
 	{
-		PyErr_SetString(PyExc_Exception, "pcilib_t handler not initialized");
+		setPyExeptionText("pcilib_t handler not initialized");
 		return NULL;
 	}
     
@@ -70,56 +173,69 @@ PyObject* read_register(const char *regname, const char *bank)
 	err = pcilib_read_register(__ctx, bank, regname, &reg_value);
 	if(err)
 	{
-		PyErr_SetString(PyExc_Exception, "Failed: read_register");
+		setPyExeptionText("Failed: read_register (%i)", err);
 		return NULL;
 	}
 	
 	err = pcilib_set_value_from_register_value(__ctx, &val, reg_value);
-	
 	if(err)
 	{
-		PyErr_SetString(PyExc_Exception, "Failed: pcilib_set_value_from_register_value");
+		setPyExeptionText("Failed: pcilib_set_value_from_register_value (%i)", err);
 		return NULL;
 	}
 
-	switch(val.type)
+    return pcilib_convert_val_to_pyobject(__ctx, &val, setPyExeptionText);
+}
+
+
+PyObject* get_property(const char *prop)
+{
+	if(!__ctx)
 	{
-		case PCILIB_TYPE_INVALID:
-			PyErr_SetString(PyExc_Exception, "Invalid register output type (PCILIB_TYPE_INVALID)");
-			return NULL;
-			
-		case PCILIB_TYPE_STRING:
-			PyErr_SetString(PyExc_Exception, "Invalid register output type (PCILIB_TYPE_STRING)");
-			return NULL;
-		
-		case PCILIB_TYPE_LONG:
-		{
-			long ret;
-			ret = pcilib_get_value_as_int(__ctx, &val, &err);
-			
-			if(err)
-			{
-				PyErr_SetString(PyExc_Exception, "Failed: pcilib_get_value_as_int");
-				return NULL;
-			}
-			return PyInt_FromLong((long) ret);
-		}
-		
-		case PCILIB_TYPE_DOUBLE:
-		{
-			double ret;
-			ret = pcilib_get_value_as_float(__ctx, &val, &err);
-			
-			if(err)
-			{
-				PyErr_SetString(PyExc_Exception, "Failed: pcilib_get_value_as_int");
-				return NULL;
-			}
-			return PyFloat_FromDouble((double) ret);
-		}
-		
-		default:
-			PyErr_SetString(PyExc_Exception, "Invalid register output type (unknown)");
+		setPyExeptionText("pcilib_t handler not initialized");
+		return NULL;
+	}
+	
+	int err;
+	pcilib_value_t val = {0};
+	
+	err  = pcilib_get_property(__ctx, prop, &val);
+	
+	if(err)
+	{
+			setPyExeptionText("Failed pcilib_get_property (%i)", err);
 			return NULL;
 	}
+	
+    return pcilib_convert_val_to_pyobject(__ctx, &val, setPyExeptionText);
+}
+
+PyObject* set_property(const char *prop, PyObject* val)
+{
+	int err;
+	
+	if(!__ctx)
+	{
+		setPyExeptionText("pcilib_t handler not initialized");
+		return NULL;
+	}
+	
+	pcilib_value_t val_internal = {0};
+	err = pcilib_convert_pyobject_to_val(__ctx, val, &val_internal);
+	if(err)
+	{
+		setPyExeptionText("pcilib_convert_pyobject_to_val (%i)", err);
+		return NULL;
+	}
+	
+	err  = pcilib_set_property(__ctx, prop, &val_internal);
+	
+	if(err)
+	{
+		setPyExeptionText("Failed pcilib_get_property (%i)", err);
+		return NULL;
+	}
+	
+	return PyInt_FromLong((long)1);
 }
+

+ 3 - 1
pcilib/pcipywrap.i

@@ -2,4 +2,6 @@
 
 extern PyObject* read_register(const char *regname, const char *bank = NULL);
 extern PyObject* __createPcilibInstance(const char *fpga_device, const char *model = NULL);
-extern void __setPcilib(PyObject* addr);
+extern PyObject* __setPcilib(PyObject* addr);
+extern PyObject* get_property(const char *prop);
+extern PyObject* set_property(const char *prop, PyObject* val);

+ 45 - 15
pcilib/xml.c

@@ -50,7 +50,6 @@
 #define BIT_REGISTERS_PATH ((xmlChar*)"./field") 				/**< all bits registers nodes */
 #define REGISTER_VIEWS_PATH ((xmlChar*)"./view") 				/**< supported register & field views */
 #define TRANSFORM_VIEWS_PATH ((xmlChar*)"/model/transform")		/**< path to complete nodes of views */
-#define SCRIPT_VIEWS_PATH ((xmlChar*)"/model/script")			/**< path to complete nodes of views */
 #define ENUM_VIEWS_PATH ((xmlChar*)"/model/enum")	 			/**< path to complete nodes of views */
 #define ENUM_ELEMENTS_PATH ((xmlChar*)"./name") 				/**< all elements in the enum */
 #define UNITS_PATH ((xmlChar*)"/model/unit")	 				/**< path to complete nodes of units */
@@ -575,8 +574,9 @@ static int pcilib_xml_create_script_view(pcilib_t *ctx, xmlXPathContextPtr xpath
 			//write script name to struct
 			desc.script_name = malloc(strlen(value));
 			sprintf(desc.script_name, "%s", value);
-			//set read access
+			//set read write access
 			mode |= PCILIB_ACCESS_R;
+			mode |= PCILIB_ACCESS_W;
             }
     }
     
@@ -589,7 +589,6 @@ static int pcilib_xml_create_script_view(pcilib_t *ctx, xmlXPathContextPtr xpath
     return 0;
 }
 
-
 static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDocPtr doc, xmlNodePtr node) {
     int err;
     xmlAttrPtr cur;
@@ -644,6 +643,46 @@ static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xp
     return 0;
 }
 
+static int pcilib_xml_create_script_or_transform_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDocPtr doc, xmlNodePtr node) {
+    int err;
+    xmlAttrPtr cur;
+    const char *name;
+
+    int has_read_from_register = 0;
+    int has_write_to_register = 0;
+    int has_script = 0;
+
+    //getting transform name in case of error
+    pcilib_view_description_t desc = {0};
+    err = pcilib_xml_parse_view(ctx, xpath, doc, node, &desc);
+
+    for (cur = node->properties; cur != NULL; cur = cur->next) {
+        if (!cur->children) continue;
+        if (!xmlNodeIsText(cur->children)) continue;
+
+        name = (char*)cur->name;
+
+        if (!strcasecmp(name, "read_from_register"))
+            has_read_from_register = 1;
+        if (!strcasecmp(name, "write_to_register"))
+            has_write_to_register = 1;
+        if (!strcasecmp(name, "script"))
+            has_script = 1;
+    }
+
+    if (has_script && (has_read_from_register || has_write_to_register)) {
+        pcilib_error("Invalid transform group attributes specified in XML property (%s)."
+                     "Transform could not contains both script and read_from_register"
+                     " or write_to_register attributes at same time.", desc.name);
+        return PCILIB_ERROR_INVALID_DATA;
+    }
+
+    if(has_script)
+        return pcilib_xml_create_script_view(ctx, xpath, doc, node);
+    else
+        return pcilib_xml_create_transform_view(ctx, xpath, doc, node);
+}
+
 
 static int pcilib_xml_parse_value_name(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDocPtr doc, xmlNodePtr node, pcilib_register_value_name_t *desc) {
     xmlAttr *cur;
@@ -869,14 +908,13 @@ static int pcilib_xml_create_unit(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDo
  */
 static int pcilib_xml_process_document(pcilib_t *ctx, xmlDocPtr doc, xmlXPathContextPtr xpath) {
     int err;
-    xmlXPathObjectPtr bank_nodes = NULL, transform_nodes = NULL, enum_nodes = NULL, unit_nodes = NULL, script_nodes = NULL;
+    xmlXPathObjectPtr bank_nodes = NULL, transform_nodes = NULL, enum_nodes = NULL, unit_nodes = NULL;
     xmlNodeSetPtr nodeset;
     int i;
 
     bank_nodes = xmlXPathEvalExpression(BANKS_PATH, xpath);
     if (bank_nodes) transform_nodes = xmlXPathEvalExpression(TRANSFORM_VIEWS_PATH, xpath);
-    if (transform_nodes) script_nodes = xmlXPathEvalExpression(SCRIPT_VIEWS_PATH, xpath);
-    if (script_nodes) enum_nodes = xmlXPathEvalExpression(ENUM_VIEWS_PATH, xpath);
+    if (transform_nodes) enum_nodes = xmlXPathEvalExpression(ENUM_VIEWS_PATH, xpath);
     if (enum_nodes) unit_nodes = xmlXPathEvalExpression(UNITS_PATH, xpath);
     
 
@@ -899,19 +937,11 @@ static int pcilib_xml_process_document(pcilib_t *ctx, xmlDocPtr doc, xmlXPathCon
 	    if (err) pcilib_error("Error (%i) creating unit", err);
         }
     }
-    
-    nodeset = script_nodes->nodesetval;
-    if(!xmlXPathNodeSetIsEmpty(nodeset)) {
-        for(i=0; i < nodeset->nodeNr; i++) {
-			err = pcilib_xml_create_script_view(ctx, xpath, doc, nodeset->nodeTab[i]);
-	    if (err) pcilib_error("Error (%i) creating script transform", err);
-        }
-    }
 
     nodeset = transform_nodes->nodesetval;
     if (!xmlXPathNodeSetIsEmpty(nodeset)) {
         for(i=0; i < nodeset->nodeNr; i++) {
-            err = pcilib_xml_create_transform_view(ctx, xpath, doc, nodeset->nodeTab[i]);
+            err = pcilib_xml_create_script_or_transform_view(ctx, xpath, doc, nodeset->nodeTab[i]);
 	    if (err) pcilib_error("Error (%i) creating register transform", err);
         }
     }

+ 70 - 21
views/script.c

@@ -4,17 +4,15 @@
 #include <stdlib.h>
 
 #include "pci.h"
+#include "pcipywrap.h"
 #include "error.h"
 
 #include "model.h"
 #include "script.h"
 
-static int pcilib_script_view_read(pcilib_t *ctx, pcilib_view_context_t *view_ctx, pcilib_register_value_t regval, pcilib_value_t *val) {
-	
+static int pcilib_script_view_module_init(pcilib_t *ctx, pcilib_script_view_description_t *v)
+{
 	int err;
-
-    const pcilib_model_description_t *model_info = pcilib_get_model_description(ctx);
-    pcilib_script_view_description_t *v = (pcilib_script_view_description_t*)(model_info->views[view_ctx->view]);
 	
 	//Initialize python script, if it has not initialized already.
 	if(!v->py_script_module)
@@ -103,6 +101,19 @@ static int pcilib_script_view_read(pcilib_t *ctx, pcilib_view_context_t *view_ct
                                NULL);
 	}
 	
+	return 0;
+}
+
+static int pcilib_script_view_read(pcilib_t *ctx, pcilib_view_context_t *view_ctx, pcilib_register_value_t regval, pcilib_value_t *val) {
+	
+	int err;
+
+    const pcilib_model_description_t *model_info = pcilib_get_model_description(ctx);
+    pcilib_script_view_description_t *v = (pcilib_script_view_description_t*)(model_info->views[view_ctx->view]);
+	
+	err = pcilib_script_view_module_init(ctx, v);
+	if(err)
+		return err;
 	
 	PyObject *ret = PyObject_CallMethod(v->py_script_module, "read_from_register", "()");
 	if (!ret) 
@@ -112,30 +123,68 @@ static int pcilib_script_view_read(pcilib_t *ctx, pcilib_view_context_t *view_ct
 	   return PCILIB_ERROR_FAILED;
 	}
 	
-	if(PyInt_Check(ret))
+	err = pcilib_convert_pyobject_to_val(ctx, ret, val);
+	
+	if(err)
 	{
-		err = pcilib_set_value_from_int(ctx, val, PyInt_AsLong(ret));
+		pcilib_error("Failed to convert python script return value to internal type: %i", err);
+		return err;
 	}
-	else
-		if(PyFloat_Check(ret))
-			err = pcilib_set_value_from_float(ctx, val, PyFloat_AsDouble(ret));
-		else
-			if(PyString_Check(ret))
-				err = pcilib_set_value_from_static_string(ctx, val, PyString_AsString(ret));
-				else
-				{
-					pcilib_error("Invalid return type in read_from_register() method. Return type should be int, float or string.");
-					return PCILIB_ERROR_NOTSUPPORTED;
-				}
+    return 0;
+}
+
+static int pcilib_script_view_write(pcilib_t *ctx, pcilib_view_context_t *view_ctx, pcilib_register_value_t *regval, pcilib_value_t *val) {
+	
+	int err;
+
+    const pcilib_model_description_t *model_info = pcilib_get_model_description(ctx);
+    pcilib_script_view_description_t *v = (pcilib_script_view_description_t*)(model_info->views[view_ctx->view]);
+	
+	err = pcilib_script_view_module_init(ctx, v);
 	if(err)
+		return err;
+		
+	PyObject *input = pcilib_convert_val_to_pyobject(ctx, val, printf);
+	if(!input)
 	{
-		pcilib_error("Failed to convert python script return value to internal type: %i", err);
+	   printf("Failed to convert input value to Python object");
+	   PyErr_Print();
+	   return PCILIB_ERROR_FAILED;
+	}
+	
+	PyObject *ret = PyObject_CallMethodObjArgs(v->py_script_module,
+											   PyUnicode_FromString("write_to_register"),
+											   input,
+											   NULL);
+	if (!ret) 
+	{
+	   printf("Python script error: ");
+	   PyErr_Print();
+	   return PCILIB_ERROR_FAILED;
+	}
+	
+	//convert output value back to pcilib_value_t
+	//no need because it wont be used later, and the script return could be none
+	/*
+	err = pcilib_convert_pyobject_to_val(ctx, ret, val);
+	if(err)
+	{
+		pcilib_error("failed to convert script write_to_register function return value to internal type: %i", err);
 		return err;
 	}
+	
+	uint64_t output = pcilib_get_value_as_register_value(ctx, val, &err);
+	if(err)
+	{
+		pcilib_error("failed to convert value to register value (%i)", err);
+		return err;
+	}
+	regval[0] = output;
+	*/
+
     return 0;
 }
 
- 
 void pcilib_script_view_free_description (pcilib_t *ctx, pcilib_view_description_t *view)
 {
 	pcilib_script_view_description_t *v = (pcilib_script_view_description_t*)(view);
@@ -154,4 +203,4 @@ void pcilib_script_view_free_description (pcilib_t *ctx, pcilib_view_description
 }
 
 const pcilib_view_api_description_t pcilib_script_view_api =
-  { PCILIB_VERSION, sizeof(pcilib_script_view_description_t), NULL, NULL, pcilib_script_view_free_description, pcilib_script_view_read, NULL};
+  { PCILIB_VERSION, sizeof(pcilib_script_view_description_t), NULL, NULL, pcilib_script_view_free_description, pcilib_script_view_read, pcilib_script_view_write};

+ 0 - 1
xml/model.xsd

@@ -7,7 +7,6 @@
       <xsd:choice minOccurs="1" maxOccurs="unbounded">
         <xsd:element name="bank" type="pcilib_bank_t" minOccurs="0" maxOccurs="unbounded" />
         <xsd:element name="transform" type="pcilib_transform_view_t" minOccurs="0" maxOccurs="unbounded" />
-        <xsd:element name="script" type="pcilib_script_view_t" minOccurs="0" maxOccurs="unbounded" />
         <xsd:element name="enum" type="pcilib_enum_view_t" minOccurs="0" maxOccurs="unbounded" />
         <xsd:element name="unit" type="pcilib_unit_t" minOccurs="0" maxOccurs="unbounded" />
       </xsd:choice>

+ 0 - 1
xml/references.xsd

@@ -6,7 +6,6 @@
       <xsd:choice minOccurs="1" maxOccurs="unbounded">
         <xsd:element name="bank" type="pcilib_bank_t" minOccurs="0" maxOccurs="unbounded" />
         <xsd:element name="transform" type="pcilib_transform_view_t" minOccurs="0" maxOccurs="unbounded" />
-        <xsd:element name="script" type="pcilib_script_view_t" minOccurs="0" maxOccurs="unbounded" />
         <xsd:element name="enum" type="pcilib_enum_view_t" minOccurs="0" maxOccurs="unbounded">
             <xsd:key name="pcilib_value_name_key">
                 <xsd:selector xpath="name" />

+ 7 - 3
xml/test_pywrap/props.xml

@@ -1,12 +1,16 @@
 <?xml version="1.0"?>
 <model xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-  <transform path="/test/prop1" register="test_prop1" unit="C" read_from_register="(503975./1024000)*${/registers/fpga/reg1} + 28715./100" description="formula to get real fpga temperature from the fpga_temperature register in decimal"/>
-  <script path="/test/prop2"
+  <transform path="/test/prop1" 
+      register="test_prop1"
+      unit="C" 
+      read_from_register="(503975./1024000)*${/registers/fpga/reg1} + 28715./100" 
+      description="formula to get real fpga temperature from the fpga_temperature register in decimal"/>
+  <transform path="/test/prop2"
 	  register="test_prop2"
 	  unit="C"
 	  script="test_prop2.py"
 	  description="test python script #1"/>
-  <script path="/test/prop3"
+  <transform path="/test/prop3"
 	  register="test_prop3"
 	  unit="C"
 	  script="test_prop3.py"

+ 6 - 5
xml/test_pywrap/test_prop2.py

@@ -1,7 +1,8 @@
 import pcipywrap
-import os
     
-def read_from_register(): 
-    reg1_val =  pcipywrap.read_register('reg1');     
-    test_prop1_val = pcipywrap.read_register('test_prop3');
-    return test_prop1_val - reg1_val;
+def read_from_register():    
+    return pcipywrap.get_property('/registers/fpga/reg1') / 3
+    
+def write_to_register(value):    
+    pcipywrap.set_property('/registers/fpga/reg1', value*3)
+

+ 0 - 10
xml/types.xsd

@@ -70,16 +70,6 @@
           <xsd:attribute name="register" type="xsd:string" />
           <xsd:attribute name="read_from_register" type="xsd:string" />
           <xsd:attribute name="write_to_register" type="xsd:string" />
-          <!-- xsd 1.1 <xsd:assert test="(@path and not(@name)) or (not(@path) and @name)"/> -->
-        </xsd:extension>
-    </xsd:complexContent>
-  </xsd:complexType>
-  
-  <xsd:complexType name="pcilib_script_view_t">
-    <xsd:complexContent>
-        <xsd:extension base="pcilib_view_t">
-          <xsd:attribute name="path" type="xsd:string" />
-          <xsd:attribute name="register" type="xsd:string" />
           <xsd:attribute name="script" type="xsd:string" />
           <!-- xsd 1.1 <xsd:assert test="(@path and not(@name)) or (not(@path) and @name)"/> -->
         </xsd:extension>