eds-pie 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- eds_pie-1.1.0/LICENSE +21 -0
- eds_pie-1.1.0/PKG-INFO +172 -0
- eds_pie-1.1.0/README.md +159 -0
- eds_pie-1.1.0/eds_pie/__init__.py +0 -0
- eds_pie-1.1.0/eds_pie/_version.py +1 -0
- eds_pie-1.1.0/eds_pie/cip_eds_types.py +951 -0
- eds_pie-1.1.0/eds_pie/eds.py +1014 -0
- eds_pie-1.1.0/eds_pie/eds_lexer.py +393 -0
- eds_pie-1.1.0/eds_pie/eds_pie.py +229 -0
- eds_pie-1.1.0/eds_pie/references/common_object_class.json +226 -0
- eds_pie-1.1.0/eds_pie/references/edslib_schema.json +32 -0
- eds_pie-1.1.0/eds_pie/references/ethernetip_lib.json +1434 -0
- eds_pie-1.1.0/eds_pie/references/meta_eds_lib.json +780 -0
- eds_pie-1.1.0/eds_pie.egg-info/PKG-INFO +172 -0
- eds_pie-1.1.0/eds_pie.egg-info/SOURCES.txt +17 -0
- eds_pie-1.1.0/eds_pie.egg-info/dependency_links.txt +1 -0
- eds_pie-1.1.0/eds_pie.egg-info/top_level.txt +1 -0
- eds_pie-1.1.0/pyproject.toml +38 -0
- eds_pie-1.1.0/setup.cfg +4 -0
eds_pie-1.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Omid Kompani
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
eds_pie-1.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: eds_pie
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: EDS parser library for ODVA's CIP® protocol family (EtherNet/IP®, DeviceNet®, etc.)
|
|
5
|
+
Author-email: omidbimo <kompani.omid@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.8
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# EDS pie
|
|
15
|
+
|
|
16
|
+
**EDS parser library for ODVA's CIP® protocol family(EtherNet/IP®, DeviceNet®,...)**
|
|
17
|
+
|
|
18
|
+

|
|
19
|
+
|
|
20
|
+
### The following are trademarks of ODVA:
|
|
21
|
+
CIP, CIP Energy, CIP Motion, CIP Security, CIP Safety, CIP Sync, CompoNet, ControlNet, DeviceNet,
|
|
22
|
+
EtherNet/IP, QuickConnect.
|
|
23
|
+
|
|
24
|
+
Visit http://www.odva.org for product information and publications
|
|
25
|
+
|
|
26
|
+
### What is an EDS
|
|
27
|
+
An Electronic Data Sheet (EDS), in the context of industrial communication, is a plain-text file that describes a device in terms of its parameters, capabilities, and I/O data structure. It provides all information necessary to identify the device, access its data, and configure its parameters when the device supports communication protocols such as CIP or CANopen.
|
|
28
|
+
|
|
29
|
+
### What does EDS Pie offer?
|
|
30
|
+
|
|
31
|
+
* Parsing EDS text files into a structured, hierarchical representation of sections, entries, and fields, as defined by the CIP specification
|
|
32
|
+
* Programmatic creation, modification, and removal of sections, entries, and fields
|
|
33
|
+
* Serialization of in-memory EDS objects back into a valid EDS plain-text file
|
|
34
|
+
* Converting EDS data to JSON fromat
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## Setup
|
|
38
|
+
```
|
|
39
|
+
pip install git+https://github.com/omidbimo/eds_pie.git
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
**EDS Pie** consists of two primary components: a **parser/serializer** and a **semantic checker**.
|
|
44
|
+
|
|
45
|
+
To validate the contents of an Electronic Datasheet correctly, EDS Pie relies on **protocol-specific reference definitions**. These references describe the valid sections, entries, and fields as specified by **ODVA** for each supported protocol.
|
|
46
|
+
|
|
47
|
+
### Current Implementation
|
|
48
|
+
|
|
49
|
+
The current implementation provides a reference library only for **EtherNet/IP**, located at: **eds_pie/references/ethernetip_lib.json**
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### Adding Support for Other Protocols
|
|
53
|
+
|
|
54
|
+
To support additional protocols—such as **DeviceNet**—a corresponding protocol-specific reference must be added to the `eds_pie/references/` directory.
|
|
55
|
+
|
|
56
|
+
Requirements for the reference:
|
|
57
|
+
|
|
58
|
+
- Must be in **JSON format**.
|
|
59
|
+
- Must strictly conform to the schema defined in: **eds_pie/references/edslib_schema.json**
|
|
60
|
+
|
|
61
|
+
Once such a reference is added, EDS Pie can process and semantically validate EDS files for the corresponding protocol without further changes to the core codebase.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
# Demo1.py
|
|
67
|
+
|
|
68
|
+
from eds_pie import CIP_EDS
|
|
69
|
+
|
|
70
|
+
with open('demo.eds', 'r') as src:
|
|
71
|
+
eds_content = src.read()
|
|
72
|
+
|
|
73
|
+
eds = CIP_EDS(eds_content)
|
|
74
|
+
print("EDS Protocol: {}".format(eds.protocol or "Generic"))
|
|
75
|
+
|
|
76
|
+
eds.list() # Lists all objects in the EDS file
|
|
77
|
+
# or
|
|
78
|
+
print(eds) # Print the serialized EDS
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+

|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
## API Reference
|
|
87
|
+
|
|
88
|
+
### EDS object
|
|
89
|
+
|
|
90
|
+
- EDS.get_section( section_keyword, class_id ) # Get a section object by it's keyword or it's classId
|
|
91
|
+
- EDS.get_entry( section_keyword, entry_keyword ) # Get an Entry object
|
|
92
|
+
- EDS.get_field( section_keyword, entry_keyword, field_index ) # Get a Field Object by its index
|
|
93
|
+
- EDS.get_value( section_keyword, entry_keyword, field_index=0 ) # Get the value of a field
|
|
94
|
+
- EDS.has_section( section_keyword )
|
|
95
|
+
- EDS.has_entry( section_keyword, entry_keyword )
|
|
96
|
+
- EDS.has_field( section_keyword, entry_keyword, field_index )
|
|
97
|
+
- EDS.add_section( section_keyword )
|
|
98
|
+
- EDS.add_entry( section_keyword, entry_keyword )
|
|
99
|
+
- EDS.add_field( section_keyword, entry_keyword, field_value, *[field_data_type]*=None ) # field_data_type must be one of defined CIP_TYPES from cip_eds_types module
|
|
100
|
+
- EDS.list() # Lists all objects in the EDS
|
|
101
|
+
- EDS.validate() # Performs semantic validation of the EDS data structure. Validation is automatically executed after each parsing operation. It may also be invoked explicitly at any time to validate the current state of the EDS contents.
|
|
102
|
+
- EDS.save( filename, *[overwrite]*=False ) # To save the EDS contents into a file
|
|
103
|
+
- EDS.__str__() # Or str(eds) returns a pretty print string representation of the EDS objects
|
|
104
|
+
- EDS.protocol # CIP Protocol recognized during the parsing
|
|
105
|
+
- EDS.sections # Representation of all EDS sections as a dictionary of {section_keyword: section_object}
|
|
106
|
+
- EDS.hcomment # EDS File Header comment
|
|
107
|
+
- EDS.fcomment # End comment of the EDS file
|
|
108
|
+
- EDS.to_json() # Export EDS data to as a JSON object
|
|
109
|
+
|
|
110
|
+
### Section object
|
|
111
|
+
|
|
112
|
+
- Section.get_entry( entry_keyword )
|
|
113
|
+
- Section.get_field( entry_keyword, field_index )
|
|
114
|
+
- Section.get_value( entry_keyword, field_index=0 )
|
|
115
|
+
- Section.has_entry( entry_keyword )
|
|
116
|
+
- Section.add_entry( entry_keyword )
|
|
117
|
+
- Section.list()
|
|
118
|
+
- Section.entries # Representation of all EDS entries as a dictionary of {entry_keyword: entry_object}
|
|
119
|
+
- Section.name # Full descriptive name of the Section
|
|
120
|
+
- Section.hcomment # This is the comment appears before the Section
|
|
121
|
+
- Section.fcomment # This is the section appears after the section on the same line
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
### Entry object
|
|
125
|
+
|
|
126
|
+
- Entry.get_field( field_index )
|
|
127
|
+
- Entry.get_value( field_index )
|
|
128
|
+
- Entry.add_field( field_value, *[field_data_type]*=None ) # field_data_type must be one of defined CIP_TYPES from cip_eds_types module
|
|
129
|
+
- Entry.list()
|
|
130
|
+
- Entry.name # Full descriptive name of the Entry
|
|
131
|
+
- Entry.fields # Representation of all EDS fields in as a list
|
|
132
|
+
- Entry.hcomment # This is the comment appears before an Entry
|
|
133
|
+
-
|
|
134
|
+
### Field object
|
|
135
|
+
|
|
136
|
+
- Field.name # Full descriptive name of the Field
|
|
137
|
+
- Field.value # Field value in the form of python types (str, int,...)
|
|
138
|
+
- Field.data # CIP_TYPES object that holds the actuall value of the field
|
|
139
|
+
- Field.data_types # A list of valid data types (if any) for this specific field. This comes from the reference libraries
|
|
140
|
+
- Field.hcomment # This is the comment appears before a Field
|
|
141
|
+
- Field.fcomment # This is the comment appears after a Field
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
## Debug mode
|
|
145
|
+
|
|
146
|
+
To retrieve the maximum information about the parsing process, set the logging level of eds_pie to DEBUG. In the debug mode, a list of parsed tokens will be displayed.
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
import logging
|
|
150
|
+
|
|
151
|
+
logging.basicConfig(level=logging.DEBUG,
|
|
152
|
+
format='%(asctime)s - %(name)s.%(levelname)-8s %(message)s')
|
|
153
|
+
logger = logging.getLogger(__name__)
|
|
154
|
+
|
|
155
|
+
from eds_pie import eds_pie
|
|
156
|
+
|
|
157
|
+
with open('demo.eds', 'r') as srcfile:
|
|
158
|
+
eds_content = srcfile.read()
|
|
159
|
+
eds = CIP_EDS(eds_content)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+

|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
## Contributing
|
|
166
|
+
|
|
167
|
+
EDS Pie is designed to be **extensible and collaborative**. Contributions are appreciated in several forms, including:
|
|
168
|
+
|
|
169
|
+
- Adding new **protocol-specific reference libraries**.
|
|
170
|
+
- Improving or extending the functionality.
|
|
171
|
+
- Enhancing **documentation** or providing usage examples.
|
|
172
|
+
|
eds_pie-1.1.0/README.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# EDS pie
|
|
2
|
+
|
|
3
|
+
**EDS parser library for ODVA's CIP® protocol family(EtherNet/IP®, DeviceNet®,...)**
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
### The following are trademarks of ODVA:
|
|
8
|
+
CIP, CIP Energy, CIP Motion, CIP Security, CIP Safety, CIP Sync, CompoNet, ControlNet, DeviceNet,
|
|
9
|
+
EtherNet/IP, QuickConnect.
|
|
10
|
+
|
|
11
|
+
Visit http://www.odva.org for product information and publications
|
|
12
|
+
|
|
13
|
+
### What is an EDS
|
|
14
|
+
An Electronic Data Sheet (EDS), in the context of industrial communication, is a plain-text file that describes a device in terms of its parameters, capabilities, and I/O data structure. It provides all information necessary to identify the device, access its data, and configure its parameters when the device supports communication protocols such as CIP or CANopen.
|
|
15
|
+
|
|
16
|
+
### What does EDS Pie offer?
|
|
17
|
+
|
|
18
|
+
* Parsing EDS text files into a structured, hierarchical representation of sections, entries, and fields, as defined by the CIP specification
|
|
19
|
+
* Programmatic creation, modification, and removal of sections, entries, and fields
|
|
20
|
+
* Serialization of in-memory EDS objects back into a valid EDS plain-text file
|
|
21
|
+
* Converting EDS data to JSON fromat
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## Setup
|
|
25
|
+
```
|
|
26
|
+
pip install git+https://github.com/omidbimo/eds_pie.git
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
**EDS Pie** consists of two primary components: a **parser/serializer** and a **semantic checker**.
|
|
31
|
+
|
|
32
|
+
To validate the contents of an Electronic Datasheet correctly, EDS Pie relies on **protocol-specific reference definitions**. These references describe the valid sections, entries, and fields as specified by **ODVA** for each supported protocol.
|
|
33
|
+
|
|
34
|
+
### Current Implementation
|
|
35
|
+
|
|
36
|
+
The current implementation provides a reference library only for **EtherNet/IP**, located at: **eds_pie/references/ethernetip_lib.json**
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Adding Support for Other Protocols
|
|
40
|
+
|
|
41
|
+
To support additional protocols—such as **DeviceNet**—a corresponding protocol-specific reference must be added to the `eds_pie/references/` directory.
|
|
42
|
+
|
|
43
|
+
Requirements for the reference:
|
|
44
|
+
|
|
45
|
+
- Must be in **JSON format**.
|
|
46
|
+
- Must strictly conform to the schema defined in: **eds_pie/references/edslib_schema.json**
|
|
47
|
+
|
|
48
|
+
Once such a reference is added, EDS Pie can process and semantically validate EDS files for the corresponding protocol without further changes to the core codebase.
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
# Demo1.py
|
|
54
|
+
|
|
55
|
+
from eds_pie import CIP_EDS
|
|
56
|
+
|
|
57
|
+
with open('demo.eds', 'r') as src:
|
|
58
|
+
eds_content = src.read()
|
|
59
|
+
|
|
60
|
+
eds = CIP_EDS(eds_content)
|
|
61
|
+
print("EDS Protocol: {}".format(eds.protocol or "Generic"))
|
|
62
|
+
|
|
63
|
+
eds.list() # Lists all objects in the EDS file
|
|
64
|
+
# or
|
|
65
|
+
print(eds) # Print the serialized EDS
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+

|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
## API Reference
|
|
74
|
+
|
|
75
|
+
### EDS object
|
|
76
|
+
|
|
77
|
+
- EDS.get_section( section_keyword, class_id ) # Get a section object by it's keyword or it's classId
|
|
78
|
+
- EDS.get_entry( section_keyword, entry_keyword ) # Get an Entry object
|
|
79
|
+
- EDS.get_field( section_keyword, entry_keyword, field_index ) # Get a Field Object by its index
|
|
80
|
+
- EDS.get_value( section_keyword, entry_keyword, field_index=0 ) # Get the value of a field
|
|
81
|
+
- EDS.has_section( section_keyword )
|
|
82
|
+
- EDS.has_entry( section_keyword, entry_keyword )
|
|
83
|
+
- EDS.has_field( section_keyword, entry_keyword, field_index )
|
|
84
|
+
- EDS.add_section( section_keyword )
|
|
85
|
+
- EDS.add_entry( section_keyword, entry_keyword )
|
|
86
|
+
- EDS.add_field( section_keyword, entry_keyword, field_value, *[field_data_type]*=None ) # field_data_type must be one of defined CIP_TYPES from cip_eds_types module
|
|
87
|
+
- EDS.list() # Lists all objects in the EDS
|
|
88
|
+
- EDS.validate() # Performs semantic validation of the EDS data structure. Validation is automatically executed after each parsing operation. It may also be invoked explicitly at any time to validate the current state of the EDS contents.
|
|
89
|
+
- EDS.save( filename, *[overwrite]*=False ) # To save the EDS contents into a file
|
|
90
|
+
- EDS.__str__() # Or str(eds) returns a pretty print string representation of the EDS objects
|
|
91
|
+
- EDS.protocol # CIP Protocol recognized during the parsing
|
|
92
|
+
- EDS.sections # Representation of all EDS sections as a dictionary of {section_keyword: section_object}
|
|
93
|
+
- EDS.hcomment # EDS File Header comment
|
|
94
|
+
- EDS.fcomment # End comment of the EDS file
|
|
95
|
+
- EDS.to_json() # Export EDS data to as a JSON object
|
|
96
|
+
|
|
97
|
+
### Section object
|
|
98
|
+
|
|
99
|
+
- Section.get_entry( entry_keyword )
|
|
100
|
+
- Section.get_field( entry_keyword, field_index )
|
|
101
|
+
- Section.get_value( entry_keyword, field_index=0 )
|
|
102
|
+
- Section.has_entry( entry_keyword )
|
|
103
|
+
- Section.add_entry( entry_keyword )
|
|
104
|
+
- Section.list()
|
|
105
|
+
- Section.entries # Representation of all EDS entries as a dictionary of {entry_keyword: entry_object}
|
|
106
|
+
- Section.name # Full descriptive name of the Section
|
|
107
|
+
- Section.hcomment # This is the comment appears before the Section
|
|
108
|
+
- Section.fcomment # This is the section appears after the section on the same line
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
### Entry object
|
|
112
|
+
|
|
113
|
+
- Entry.get_field( field_index )
|
|
114
|
+
- Entry.get_value( field_index )
|
|
115
|
+
- Entry.add_field( field_value, *[field_data_type]*=None ) # field_data_type must be one of defined CIP_TYPES from cip_eds_types module
|
|
116
|
+
- Entry.list()
|
|
117
|
+
- Entry.name # Full descriptive name of the Entry
|
|
118
|
+
- Entry.fields # Representation of all EDS fields in as a list
|
|
119
|
+
- Entry.hcomment # This is the comment appears before an Entry
|
|
120
|
+
-
|
|
121
|
+
### Field object
|
|
122
|
+
|
|
123
|
+
- Field.name # Full descriptive name of the Field
|
|
124
|
+
- Field.value # Field value in the form of python types (str, int,...)
|
|
125
|
+
- Field.data # CIP_TYPES object that holds the actuall value of the field
|
|
126
|
+
- Field.data_types # A list of valid data types (if any) for this specific field. This comes from the reference libraries
|
|
127
|
+
- Field.hcomment # This is the comment appears before a Field
|
|
128
|
+
- Field.fcomment # This is the comment appears after a Field
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
## Debug mode
|
|
132
|
+
|
|
133
|
+
To retrieve the maximum information about the parsing process, set the logging level of eds_pie to DEBUG. In the debug mode, a list of parsed tokens will be displayed.
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
import logging
|
|
137
|
+
|
|
138
|
+
logging.basicConfig(level=logging.DEBUG,
|
|
139
|
+
format='%(asctime)s - %(name)s.%(levelname)-8s %(message)s')
|
|
140
|
+
logger = logging.getLogger(__name__)
|
|
141
|
+
|
|
142
|
+
from eds_pie import eds_pie
|
|
143
|
+
|
|
144
|
+
with open('demo.eds', 'r') as srcfile:
|
|
145
|
+
eds_content = srcfile.read()
|
|
146
|
+
eds = CIP_EDS(eds_content)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+

|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
## Contributing
|
|
153
|
+
|
|
154
|
+
EDS Pie is designed to be **extensible and collaborative**. Contributions are appreciated in several forms, including:
|
|
155
|
+
|
|
156
|
+
- Adding new **protocol-specific reference libraries**.
|
|
157
|
+
- Improving or extending the functionality.
|
|
158
|
+
- Enhancing **documentation** or providing usage examples.
|
|
159
|
+
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.1.0"
|