- better logging of drivers

git-svn-id: http://moon:8086/svn/projects/HendiControl@363 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
2020-04-19 16:05:53 +00:00
parent b51e2c222d
commit 95afea668f
6 changed files with 48 additions and 22 deletions
+15 -6
View File
@@ -4,8 +4,18 @@ import time
import serial
import sys
import numpy as np
import logging
class HendiCtrl():
def name(self):
return "HendiCtrl"
def log(self, s):
d = {'user': self.name()}
logging.info ("{}".format(s), extra=d)
def __init__(self, port, baudrate):
self.ser = serial.Serial(port, baudrate)
try:
@@ -17,8 +27,8 @@ class HendiCtrl():
self.ser.timeout = 1.000
self.prompt = b':'
self.caps = {
"name" : self.getSoftwareIdentifier(),
"ver" : self.getSoftwareVersion(),
"sw_id" : self.getSoftwareIdentifier(),
"sw_ver" : self.getSoftwareVersion(),
"pwr_watts_min" : 500,
"pwr_watts_max" : 3500,
"pwr_watts_step" : 100,
@@ -29,7 +39,9 @@ class HendiCtrl():
digits = [4092, 3840, 3700, 3440, 3300, 3060, 3000, 2930, 2860, 2780, 2640, 2510, 2430, 2360, 2190, 2130, 2030, 1980, 1880, 1730, 1630, 1560, 1480, 1400, 1240, 1150, 1150, 1080, 920, 740, 670]
self.poly_w2d = np.polyfit(powers, digits, 5)
self.poly_d2w = np.polyfit(digits, powers, 5)
self.name = self.getSoftwareIdentifier()
self.sw_id = self.getSoftwareIdentifier()
self.sw_ver = self.getSoftwareVersion()
self.log("Create {}, Version {}".format(self.sw_id, self.sw_ver))
def toDigits(self, power_watts):
return np.polyval(self.poly_w2d, float(power_watts))
@@ -103,9 +115,6 @@ class HendiCtrl():
rsp = self.__read()
if "OK" in rsp[0]:
return rsp[1]
# print("{}: Command : {}".format(self.name), req)
# print("{}: Response: {}".format(self.name), rsp)
# print("{}: Received error!".format(self.name))
return None
def getCapabilties(self):