forked from veles_labs/pyveles
Added .veles_metadata
This commit is contained in:
parent
3c6b2a768c
commit
9c4504b1f3
0
.veles_metadata
Normal file
0
.veles_metadata
Normal file
@ -1 +1 @@
|
||||
from . import devices
|
||||
from . import device
|
||||
|
@ -1,6 +1,7 @@
|
||||
"""Module containing classes for generic wired/wireless devices"""
|
||||
from dataclasses import dataclass
|
||||
from typing import Dict, Final
|
||||
from typing import Dict, Final, Any
|
||||
from abc import ABC, abstractmethod
|
||||
import minimalmodbus
|
||||
import serial
|
||||
|
||||
@ -26,8 +27,17 @@ class ReadoutErrorCounter:
|
||||
no_response: int = 0
|
||||
|
||||
|
||||
class Device:
|
||||
"""Base class for all devices"""
|
||||
class Device(ABC):
|
||||
"""
|
||||
Base class for all devices
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def get_data(self) -> Dict[str:Any]:
|
||||
"""
|
||||
Get dict with all data from sensor;
|
||||
used for logging purposes
|
||||
"""
|
||||
|
||||
|
||||
class ModbusRTUDevice(Device):
|
||||
@ -89,7 +99,8 @@ class ModbusRTUDevice(Device):
|
||||
return (
|
||||
self.comm_device.read_register(
|
||||
register_offset, 1, functioncode=function_code, signed=signed
|
||||
) * 10
|
||||
)
|
||||
* 10
|
||||
)
|
||||
except minimalmodbus.NoResponseError as exception:
|
||||
last_exception = exception
|
||||
@ -158,5 +169,7 @@ class ModbusRTUDevice(Device):
|
||||
Return serial number
|
||||
"""
|
||||
serial_number_1 = self.device_code
|
||||
serial_number_2 = int(self.read_register(self.input_registers["SERIAL_NUMBER_2"]))
|
||||
serial_number_2 = int(
|
||||
self.read_register(self.input_registers["SERIAL_NUMBER_2"])
|
||||
)
|
||||
return (serial_number_1 << 16) + serial_number_2
|
Loading…
Reference in New Issue
Block a user