Skip to content

Commit

Permalink
Merge pull request #28 from RWTH-EBC/27-init-error-for-system-without…
Browse files Browse the repository at this point in the history
…-twincat

27 init error for system without twincat
  • Loading branch information
Jun-Jiang-92 authored Nov 22, 2024
2 parents f8c901e + 4a61e0a commit bbc3a2a
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 14 deletions.
13 changes: 12 additions & 1 deletion ebcmeasurements/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
from .Base import Auxiliary, DataLogger, DataOutput, DataSource
from .Beckhoff import AdsDataSourceOutput
from .Icpdas import IcpdasDataSourceOutput
from .Mqtt import MqttDataSourceOutput, MqttTheThingsNetwork
from .Sensor_Electronic import SensoSysDataSource
import logging

try:
from .Beckhoff import AdsDataSourceOutput
except FileNotFoundError as e:
# Without TwinCAT installed in system, 'FileNotFoundError' will be raised by Pyads due to missing 'TcAdsDll.dll'.
# Ref1: https://github.com/stlehmann/pyads/issues/105
# Ref2: https://stackoverflow.com/questions/76305160/windows-10-python-pyads-library-error-could-not-find-module-tcadsdll-dll
logging.warning(
f"Without TwinCAT installed on the system, 'AdsDataSourceOutput' submodule will not be available. "
f"Original error: {e}")
except ImportError as e:
logging.error(f"Failed to import 'AdsDataSourceOutput': {e}")

# Configure the root logger with a default leve and format
logging.basicConfig(
level=logging.INFO, # Set the default logging level
Expand Down
2 changes: 1 addition & 1 deletion examples/e01_basic_structure_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
3. Configuration of data logger(s)
"""
from ebcmeasurements.Base import DataSource, DataOutput, DataLogger
from ebcmeasurements import DataSource, DataOutput, DataLogger


def e01_basic_structure_example():
Expand Down
2 changes: 1 addition & 1 deletion examples/e02_multiple_sources_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
variable names may have duplicates across different sources, which can lead to ambiguity in the logged data. This
example shows how to address this issue.
"""
from ebcmeasurements.Base import DataSource, DataOutput, DataLogger
from ebcmeasurements import DataSource, DataOutput, DataLogger


def e02_multiple_sources_outputs():
Expand Down
3 changes: 1 addition & 2 deletions examples/e03_sensor_electronic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
NOTICE: The measuring system must be connected to the PC in order to run this example.
"""
from ebcmeasurements.Base import DataOutput, DataLogger
from ebcmeasurements.Sensor_Electronic import SensoSysDataSource
from ebcmeasurements import DataOutput, DataLogger, SensoSysDataSource


def e03_sensor_electronic():
Expand Down
3 changes: 1 addition & 2 deletions examples/e04_beckhoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
NOTICE: Load the project "EBC Measurements TwinCAT" to a Beckhoff PLC in order to run this example
"""
from ebcmeasurements.Base import DataSource, DataOutput, DataLogger
from ebcmeasurements.Beckhoff import AdsDataSourceOutput
from ebcmeasurements import DataSource, DataOutput, DataLogger, AdsDataSourceOutput


def e04_beckhoff():
Expand Down
3 changes: 1 addition & 2 deletions examples/e05_mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
NOTICE: Internet connection is necessary to run this example; Install a MQTT explorer (http://mqtt-explorer.com/) to
monitor data by subscribing topic 'ebc_measurements/#'
"""
from ebcmeasurements.Base import DataSource, DataOutput, DataLogger
from ebcmeasurements.Mqtt import MqttDataSourceOutput
from ebcmeasurements import DataSource, DataOutput, DataLogger, MqttDataSourceOutput


def e05_mqtt():
Expand Down
3 changes: 1 addition & 2 deletions examples/e06_icpdas.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
NOTICE 1: Hardware (I/O units with I/O modules) are necessary to run this example
NOTICE 2: The package now only supports I-87K system
"""
from ebcmeasurements.Base import DataOutput, DataLogger
from ebcmeasurements.Icpdas import IcpdasDataSourceOutput
from ebcmeasurements import DataOutput, DataLogger, IcpdasDataSourceOutput


def e05_icpdas():
Expand Down
3 changes: 1 addition & 2 deletions examples/e07_ttn.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
NOTICE: Registered IoT-device in the TTN and internet connection are necessary to run this example
"""
from ebcmeasurements.Base import DataOutput
from ebcmeasurements.Mqtt import MqttTheThingsNetwork
from ebcmeasurements import DataOutput, MqttTheThingsNetwork


def e07_ttn():
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='EBC-Measurements',
version='1.2.0',
version='1.2.1',
author='RWTH Aachen University, E.ON Energy Research Center, '
'Institute for Energy Efficient Buildings and Indoor Climate',
author_email='[email protected]',
Expand Down

0 comments on commit bbc3a2a

Please sign in to comment.