Skip to content

Commit

Permalink
Merge branch 'RobertoRoos-feature/init-import'
Browse files Browse the repository at this point in the history
  • Loading branch information
bnjmnp committed Jul 7, 2024
2 parents fcc6491 + 9ba1079 commit 585e3cb
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 13 deletions.
2 changes: 0 additions & 2 deletions pysoem/__init__.py

This file was deleted.

7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def find_version(*file_paths):
extensions = [
Extension(
'pysoem.pysoem',
['pysoem/pysoem'+ext] + soem_sources,
['src/pysoem/pysoem'+ext] + soem_sources,
define_macros=soem_macros,
libraries=soem_libs,
library_dirs=soem_lib_dirs,
Expand All @@ -96,7 +96,7 @@ def find_version(*file_paths):
extensions = cythonize(extensions, compiler_directives={"language_level": "2"})

setup(name='pysoem',
version=find_version("pysoem", "__init__.py"),
version=find_version("src", "pysoem", "__init__.py"),
description='Cython wrapper for the SOEM Library',
author='Benjamin Partzsch',
author_email='[email protected]',
Expand All @@ -105,6 +105,7 @@ def find_version(*file_paths):
long_description=readme(),
ext_modules=extensions,
packages=['pysoem'],
package_dir={"": "src"},
project_urls={
'Documentation': 'https://pysoem.readthedocs.io',
},
Expand All @@ -118,4 +119,4 @@ def find_version(*file_paths):
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Scientific/Engineering',
]
)
)
58 changes: 58 additions & 0 deletions src/pysoem/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
__version__ = '1.1.6'


# Classes:
from pysoem.pysoem import (
Master,
SdoError,
Emergency,
SdoInfoError,
MailboxError,
PacketError,
ConfigMapError,
EepromError,
WkcError,
SiiOffset,
)

# State constants:
from pysoem.pysoem import (
NONE_STATE,
INIT_STATE,
PREOP_STATE,
BOOT_STATE,
SAFEOP_STATE,
OP_STATE,
STATE_ACK,
STATE_ERROR,
)

# ECT constants:
from pysoem.pysoem import (
ECT_REG_WD_DIV,
ECT_REG_WD_TIME_PDI,
ECT_REG_WD_TIME_PROCESSDATA,
ECT_REG_SM0,
ECT_REG_SM1,
ECT_COEDET_SDO,
ECT_COEDET_SDOINFO,
ECT_COEDET_PDOASSIGN,
ECT_COEDET_PDOCONFIG,
ECT_COEDET_UPLOAD,
ECT_COEDET_SDOCA,
ec_datatype,
)

# Functions:
from pysoem.pysoem import (
find_adapters,
open,
al_status_code_to_string,
)

# Raw Cdefs:
from pysoem.pysoem import (
CdefMaster,
CdefSlave,
CdefCoeObjectEntry,
)
4 changes: 4 additions & 0 deletions pysoem/cpysoem.pxd → src/pysoem/cpysoem.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#
"""PySOEM is a Cython wrapper for the SOEM library."""

#
# This creates a helper library for PySOEM, to be used with `cimport cpysoem`
#

from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t

cdef extern from "ethercat.h":
Expand Down
20 changes: 12 additions & 8 deletions pysoem/pysoem.pyx → src/pysoem/pysoem.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#
"""PySOEM is a Cython wrapper for the SOEM library."""

#
# This will result in the creation of the `pysoem.pysoem` module.
#

cimport cpysoem

import sys
Expand Down Expand Up @@ -85,10 +89,10 @@ cdef struct CdefMasterSettings:

def find_adapters():
"""Create a list of available network adapters.
Returns:
list[Adapter]: Each element of the list has a name an desc attribute.
"""
cdef cpysoem.ec_adaptert* _ec_adapter = cpysoem.ec_find_adapters()
Adapter = collections.namedtuple('Adapter', ['name', 'desc'])
Expand All @@ -110,7 +114,7 @@ def open(ifname):
yield master
master.close()


def al_status_code_to_string(code):
"""Look up text string that belongs to AL status code.
Expand All @@ -122,11 +126,11 @@ def al_status_code_to_string(code):
"""
return cpysoem.ec_ALstatuscode2string(code).decode('utf8');


class Master(CdefMaster):
"""Representing a logical EtherCAT master device.
For each network interface you can have a Master instance.
Attributes:
Expand All @@ -135,8 +139,8 @@ class Master(CdefMaster):
sdo_write_timeout: timeout for SDO write access for all slaves connected
"""
pass


cdef class CdefMaster:
"""Representing a logical EtherCAT master device.
Expand Down

0 comments on commit 585e3cb

Please sign in to comment.