569
569
desc.base.api = &pcilib_transform_view_api;
570
570
desc.base.type = PCILIB_TYPE_DOUBLE;
571
571
desc.base.mode = PCILIB_ACCESS_RW;
574
573
err = pcilib_xml_parse_view(ctx, xpath, doc, node, (pcilib_view_description_t*)&desc);
575
574
if (err) return err;
601
600
desc.write_to_reg = value;
602
601
if ((value)&&(*value)) mode |= PCILIB_ACCESS_W;
603
602
} else if (!strcasecmp(name, "script")) {
604
char* script_name = malloc(strlen(value));
605
sprintf(script_name, "%s", value);
603
desc.module = malloc(strlen(value));
604
sprintf(desc.module, "%s", value);
607
err = pcilib_init_py_script(ctx, script_name, &(desc.script), &mode);
606
err = pcilib_py_init_script(ctx, desc.module, &mode);
608
607
if(err) return err;
609
608
mode |= PCILIB_REGISTER_INCONSISTENT;
623
static int pcilib_xml_create_script_or_transform_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDocPtr doc, xmlNodePtr node) {
629
int has_read_from_register = 0;
630
int has_write_to_register = 0;
633
//getting transform name in case of error
634
pcilib_view_description_t desc = {0};
635
err = pcilib_xml_parse_view(ctx, xpath, doc, node, &desc);
637
for (cur = node->properties; cur != NULL; cur = cur->next) {
638
if (!cur->children) continue;
639
if (!xmlNodeIsText(cur->children)) continue;
641
name = (char*)cur->name;
643
if (!strcasecmp(name, "read_from_register"))
644
has_read_from_register = 1;
645
if (!strcasecmp(name, "write_to_register"))
646
has_write_to_register = 1;
647
if (!strcasecmp(name, "script"))
651
if (has_script && (has_read_from_register || has_write_to_register)) {
652
pcilib_error("Invalid transform group attributes specified in XML property (%s)."
653
"Transform could not contains both script and read_from_register"
654
" or write_to_register attributes at same time.", desc.name);
655
return PCILIB_ERROR_INVALID_DATA;
660
return pcilib_xml_create_script_view(ctx, xpath, doc, node);
663
return pcilib_xml_create_transform_view(ctx, xpath, doc, node);
667
622
static int pcilib_xml_parse_value_name(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDocPtr doc, xmlNodePtr node, pcilib_register_value_name_t *desc) {
669
624
char *value, *name;
921
876
nodeset = transform_nodes->nodesetval;
922
877
if (!xmlXPathNodeSetIsEmpty(nodeset)) {
923
878
for(i=0; i < nodeset->nodeNr; i++) {
924
err = pcilib_xml_create_script_or_transform_view(ctx, xpath, doc, nodeset->nodeTab[i]);
879
err = pcilib_xml_create_transform_view(ctx, xpath, doc, nodeset->nodeTab[i]);
925
880
if (err) pcilib_error("Error (%i) creating register transform", err);