Code Monkey home page Code Monkey logo

eds_pie's Introduction

EDS pie

A python EDS(Electronic Data Sheet) parser library for the ODVA protocol family(EthereNetIP, DeviceNet,...)

Who may need an EDS parser library

Use cases:

  • โ€‹ Batch processing of EDS files
    • To find out which devices are supporting a specific CIP object or service (i.e. CIP Security)
    • To change contents of a range of EDS files (i.e. Add a new section to all EDSs with a specific ProductCode)
  • Automation
    • To implement automated scripts/tests
      • The test script uses EDS_pie to parse the IO assembly path and starts an IO communication
      • To implement QA scripts to make sure the EDS file matches a device configuration
      • To Create new EDS files
  • Format conversion
    • To convert EDS data into other formats such as XML / JSON and feed the applications that do not understand the EDS notations

Usage

# Demo1.py
from eds_pie import *

eds = eds_pie.parse(edsfile = "demo.eds", showprogress = True)
print eds.protocol

image-demo1

# Demo2.py

from eds_pie import *

eds = eds_pie.parse(edsfile = "demo.eds", showprogress = True)
eds.list("file")

image-demo2

# Demo3.py
from eds_pie import *

eds = eds_pie.parse(edsfile = "demo.eds", showprogress = True)

print eds.getfield("file", "DescText")
print "\"{}\"".format(eds.getfield("file", "DescText").value)

image-demo3

# Demo4.py

from eds_pie import *

eds = eds_pie.parse(edsfile = "demo.eds", showprogress = True)

if eds.protocol == "EtherNetIP":
    sec = eds.getsection("device")
    if sec is not None:
        ProductType = sec.getfield("ProdType").value
        if ProductType == 12:
            print "This is an EtherNet/IP Communication adapter device."

image-demo4

API

EDS object functions

  • EDS.list( [sectionname], [entryname]) To print a list of attributes (sections, entries, fields)

  • EDS.getsection( sectionname ) To get the addressed section object

  • EDS.getentry( sectionname, entryname ) To get the addressed entry object

  • EDS.getfield( sectionname, entryname, fieldindex / fieldname ) To get the addressed field object

  • EDS.getvalue( sectionname, entryname, fieldindex / fieldname ) To get the value of an addressed field

  • EDS.setvalue( sectionname, entryname, fieldindex, value ) To set value of an addressed field

  • EDS.hassection( sectionname )

  • EDS.hasenry( sectionname, entryname )

  • EDS.hasfield( sectionname, entryname, fieldindex )

  • EDS.addsection( sectionname )

  • EDS.addentry( sectionname, entryname )

  • EDS.addfield( sectionname, entryname, fieldvalue, [fielddatatype] )

  • EDS.removesection( sectionname )

  • EDS.removeentry( sectionname, entryname )

  • EDS.removefield( sectionname, entryname, fieldindex )

  • EDS.save( [filename], [overwrite] ) To save an eds file ( it works but it doesn't beatifulize the output like the EZeds does!)

EDS object properties

  • EDS.protocol To get the string protocol name of the eds file (generic, EtherNetIP, ...)
  • EDS.sections To get the list of eds sections

Section object functions

  • section.getentry( entryname )

  • section.addentry( entryname )

  • section.getfield( entryname, fieldindex / fieldname )

Section object properties

  • section.name to get string name of the section
  • section.entrycount to get the number of entries for this section
  • section.entries to get a list of this section entries

Entry object functions

  • entry.getfield( fieldindex / fieldname )

  • entry.addfield( fieldvalue, [datatype] )

Entry object properties

  • entry.name to get string name of the entry
  • entry.fieldcount to get the number of fields for this entry
  • entry.fields to get a list of this entry fields

Field object functions

  • field.getfield( fieldindex / fieldname )

  • filed.addfield( fieldvalue, [datatype] )

Field object properties

  • field.name to get string name of the field

  • field.index to get the index of this field in the of parent entry fields

  • field.value to get / set the value of the field

  • field.datatype to get the data-type object of this field

All object are printable using the print instruction

Verbose mode

The parser also supports verbosemode to control the display output of the parsing flow. Setting the verbose modes true, will display a list of parsed tokens.

from eds_pie import *

eds = eds_pie.parse(edsfile = "demo.eds", showprogress = True, verbosemode = True)

image-demo1_verbosemode

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.