/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to pcilib/xml.c

  • Committer: Vasilii Chernov
  • Date: 2016-02-11 09:37:24 UTC
  • mto: This revision was merged to the branch mainline in revision 353.
  • Revision ID: vchernov@inr.ru-20160211093724-ipw54n5wxts1jt2i
Merge script and transform view. Add get register and properties info to python wrap.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
#include "view.h"
43
43
#include "views/enum.h"
44
44
#include "views/transform.h"
45
 
#include "views/script.h"
 
45
#include "py.h"
46
46
 
47
47
 
48
48
#define BANKS_PATH ((xmlChar*)"/model/bank")                                    /**< path to complete nodes of banks */
559
559
    xmlAttrPtr cur;
560
560
    const char *value, *name;
561
561
    pcilib_view_context_t *view_ctx;
562
 
 
563
 
    pcilib_access_mode_t mode = PCILIB_REGISTER_NO_CHK;
564
 
    pcilib_script_view_description_t desc = {{0}};
565
 
 
566
 
    desc.base.api = &pcilib_script_view_api;
 
562
    
 
563
 
 
564
    pcilib_access_mode_t mode = 0;
 
565
    pcilib_transform_view_description_t desc = {{0}};
 
566
 
 
567
    desc.base.api = &pcilib_transform_view_api;
567
568
    desc.base.type = PCILIB_TYPE_DOUBLE;
568
569
    desc.base.mode = PCILIB_ACCESS_RW;
569
 
    desc.py_script_module = NULL;
570
 
    desc.script_name = NULL;
 
570
    desc.script = NULL;
571
571
 
572
572
    err = pcilib_xml_parse_view(ctx, xpath, doc, node, (pcilib_view_description_t*)&desc);
573
573
    if (err) return err;
580
580
        value = (char*)cur->children->content;
581
581
        if (!value) continue;
582
582
 
583
 
        if (!strcasecmp(name, "script")) {
 
583
        if (!strcasecmp(name, "script")) 
 
584
        {
584
585
                        //write script name to struct
585
 
                        desc.script_name = malloc(strlen(value));
586
 
                        sprintf(desc.script_name, "%s", value);
587
 
                        //set read write access
588
 
                        mode |= PCILIB_ACCESS_R;
589
 
                        mode |= PCILIB_ACCESS_W;
590
 
            }
 
586
                        char* script_name = malloc(strlen(value));
 
587
                        sprintf(script_name, "%s", value);
 
588
                        
 
589
                        err = pcilib_init_py_script(ctx, script_name, &(desc.script), &mode);
 
590
                        if(err) return err;
 
591
                        mode |= PCILIB_REGISTER_NO_CHK;
 
592
        }
591
593
    }
592
594
    
593
595
    desc.base.mode &= mode;
611
613
    desc.base.api = &pcilib_transform_view_api;
612
614
    desc.base.type = PCILIB_TYPE_DOUBLE;
613
615
    desc.base.mode = PCILIB_ACCESS_RW;
 
616
    desc.script = NULL;
614
617
 
615
618
    err = pcilib_xml_parse_view(ctx, xpath, doc, node, (pcilib_view_description_t*)&desc);
616
619
    if (err) return err;
641
644
            }
642
645
            desc.write_to_reg = value;
643
646
            if ((value)&&(*value)) mode |= PCILIB_ACCESS_W;
644
 
        } 
 
647
        } else if (!strcasecmp(name, "script")) {
 
648
                        char* script_name = malloc(strlen(value));
 
649
                        sprintf(script_name, "%s", value);
 
650
                        
 
651
                        err = pcilib_init_py_script(ctx, script_name, &(desc.script), &mode);
 
652
                        if(err) return err;
 
653
                        mode |= PCILIB_REGISTER_NO_CHK;
 
654
                        break;
 
655
        }
645
656
    }
646
657
 
647
658
    desc.base.mode &= mode;
654
665
}
655
666
 
656
667
static int pcilib_xml_create_script_or_transform_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDocPtr doc, xmlNodePtr node) {
 
668
    /*
657
669
    int err;
658
670
    xmlAttrPtr cur;
659
671
    const char *name;
688
700
    }
689
701
 
690
702
    if(has_script)
 
703
    
691
704
        return pcilib_xml_create_script_view(ctx, xpath, doc, node);
692
705
    else
693
 
        return pcilib_xml_create_transform_view(ctx, xpath, doc, node);
 
706
    */
 
707
       return pcilib_xml_create_transform_view(ctx, xpath, doc, node);
694
708
}
695
709
 
696
710